/*求Sn = a + aa + aaa + aaaa + aaaaa的前5项之和,其中a是一个数字,例如:2 + 22 + 222 + 2222 + 22222*/

#include<stdio.h>

int main()

{

int i = 0;

int a = 0;

int sum = 0;

int num=0;

scanf("%d",&num);

for (i = 0; i < 5; i++)

{

a = a * 10 + num;

sum = sum + a;

}

printf("%d", sum);

return 0;

}

输出结果:

2

24690



             Press any key to continue