求 a+aa+aaa+...aaaaa..

SYRW1201發表於2020-12-24

#include<stdio.h>
int main()
{
int i,j,a,n,sum=0,term=0;
printf(“Input a number:”);
scanf("%d",&a);
printf(“Input a number:”);
scanf("%d",&n);
for(i=1;i<=n;i++)
{
term=term*10+a;
sum=sum+term;
}
printf(“a+aa+aaa…+a…a=%d”,sum);
return 0;

}

相關文章