#include <stdio.h>
int main()
{
int n = 0;
int i = 0;
int sum = 0;
int ntmp = 0;
printf("Please enter a number:\n");
scanf("%d",&n);
sum = n;
ntmp = n;
printf("%d",n);
for(i = 0; i < n-1; i++)
{
printf("+");
ntmp = ntmp * 10 + n;
printf("%d",ntmp);
sum += ntmp;
}
printf("\nsum = %d!\n",sum);
return 0;
}
写了一个比较土的方法,不过应该满足你的要求了。。