求Sn=a+aa+aaa+aaaa+aaaaa的前5项之和,其中a是一个数字, 例如:2+22+222+2222+22222 int main() { int a; scanf("%d", &a); int n; scanf("%d", &n); int sum = 0; int tmp = 0; for (int i = 0; i < n; i++) { tmp = tmp * 10 + a; sum += tmp; } printf("%d", sum); return 0; }