Calculation Sn = 2 + 22 + 222 + 2222 + 22222
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i = 0;
int n = 0;
int j = 0;
int temp = 0;
int sum = 0;
scanf("%d", &i);
scanf("%d", &n);
for (j = 0; j < n; j++)
{
temp = temp * 10 + i;
sum += temp;
}
printf("sum=%d", sum);
system("pause");
return 0;
}
key point
Each number is ten times before adding a i
This program can not only be considered as a dynamic title is written, did not write the dead.