新手 求S=a+aa+aaa+aaaa
# include <stdio.h># include <math.h>
int main(void)
{
int i = 1, sum = 0, a, n, k;
scanf("%d%d",&a,&n);
for ( ; k != 0 && k <= n-i; i++)
sum = sum + pow( 10,k);
sum = a * ( 1 + sum);
printf("结果是%d",sum);
return 0;
}
我想知道 ,我这个编的程序能运行,只显示窗口后,不显示结果
为什么呢》??
———————————————————分割线——————————————————————————————
我已经修改成这样
# include <stdio.h>
# include <math.h>
int main(void)
{
int sum = 0, k = 1, n, a;
scanf("%d%d",&a,&n);
for ( ; k < n; k++)
sum = sum + pow( 10,k);
sum = a * ( 1 + sum);
printf("结果是%d\n",sum);
return 0;
}
[ 本帖最后由 hanucvb 于 2011-9-23 13:15 编辑 ]