main()
{ int a,i,n; long int x=0,sum=0; scanf("%d,%d",&a,&n); if (a<=0||a>=10||n<=0) printf("error!"); for (i=0;i<=n;i++) { x=x*10+a; sum=sum+x; } printf("%ld\n",sum);
}
帮忙修改下,不知道哪里错了???
OK了!!!
main()
{
int a,i,n;
long int x=0,sum=0;
scanf("%d,%d",&a,&n);
if (a<=0||a>=10||n<=0) printf("error!"); for (i=0;i<n;i++) { x=x*10+a; sum=sum+x; } printf("%ld\n",sum);
}