#include<stdio.h>
int main()
{
int a = 0;
int n = 0;
int sum = 0;
int tmp = 0;
int i = 0;
scanf("%d%d", &a, &n);
for (i = 0; i < n; i++)
{
tmp = a + tmp * 10;
sum = sum + tmp;
}
printf("sum=%d", sum);
system("pause");
return 0;
}
求Sn=a+aa+aaa+aaaa+aaaaa的前5项之和,其中a是一个数字,例如:2+22+222+2222+22222
原文地址:http://10942013.blog.51cto.com/10932013/1722551