c17
计算a+aa+aaa+aaaa+…+aaa…aaa(n个a)的值,n和a的值由键盘输入
#include<stdio.h>
#include<math.h>
int main()
{
int n, sum = 0, a,i=0;
int temp = 0;
printf("输入两个数\n");
scanf("%d,%d", &a, &n);
while (i < n)
{
int c = a * pow((double)10,(double) i);
temp += c;
sum += temp;
i++;
}
printf("%d\n", sum);
return 0;
}