你的原程序:
#include<stdio.h>
int main(void)
{
int i = 1, k;
float j, sum =0;
printf ("请输入所要计算的数字,按0结束输入:\n\n");
do {
printf (" %d、", i);
scanf ("%f", &j);
printf ("\n");
sum = sum + j;
i++;
}
while ( j != 0 );
printf (" sum = %.2f\n\n\n 按0退出,按1继续:", sum);
scanf("%d",&k);
return 0;
}
改进后的程序:
#include<stdio.h>
int main(void)
{
int i = 1, k=1;
float j, sum =0.0;
for(;k!=0;++i)
{
printf("%d====Please enter the numbler:\n\n",i);
scanf("%f",&j);
sum+=j;
printf("\nsum=%.2f\ncontinue----1\nend-------0\n",sum);
scanf("%d",&k);
}
return 0;
}
几点意见:
1在程序中最好都用英文,因为一般的TC不支持中文
2程序语段要安排好,便与检查