程序: //求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 = s
#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("paus
#include<stdio.h> int main() { int sum=0; int i=0; int a=0; int num; scanf("%d",&num); for(i=0;i<5;i++) { a=a*10+num; sum+=a; } printf("%d",sum); return 0; }
#include <stdio.h> int main(){ int num = 0; int count = 0; int sum = 0; scanf("%d%d", &num, &count); int i = 0; int tmp = num; for (i = 0; i < count; i++) { sum += num; num = num * 10 + tmp; } printf("%d\n", sum)
#include<stdio.h> #include<stdlib.h> int main() { int a,sum; scanf("%d", &a); if ((a<10) && (a>0)) { sum = a; sum = sum + a + a * 10; sum = sum + a + a * 10 + a * 100; sum = sum + a + a * 10 + a * 100 + a * 1000; su