# include
int main()
{
int sum,a,n,i,c;
c=a;//a没有初值,数值不定而赋给c
printf("Please input n and a\n");
scanf("%d,%d",&n,&a);
for(sum=0,i=0;i {
sum=sum+a;
a=c+a*10;//导致这里出错
}
printf("The answer is%d\n",sum);
return 0;
}
==================================================================
# include
# include
int main()
{
int a,n,i;
double sum;
printf("Please input n and a:");
scanf("%d,%d",&n,&a);
for(i=n-1,sum=0;i>=0;i--)
sum+=(pow(a,(n-i)));
/*
for(i=n-1,sum=n*a;i>0;i--)
sum+=(n-i)*a*(pow(10,i));
*/
printf("The answer is %10.0lf\n\n",sum);
}