如:2+22+222+2222+22222
#include <stdio.h>
int main()
{
int i, n = 2, sum = 0;
for (i = 1; i <= 6; i++){
sum += n;
n = n * 10 + 2;
}
printf("%d\n", sum);
return 0;
}
如:2+22+222+2222+22222
#include <stdio.h>
int main()
{
int i, n = 2, sum = 0;
for (i = 1; i <= 6; i++){
sum += n;
n = n * 10 + 2;
}
printf("%d\n", sum);
return 0;
}