- 论坛徽章:
- 0
|
各位大哥,帮我看看下面这个程序.
/* credit limit test program for department store */
#include<stdio.h>;
main ()
{
/* bening stat */
int account =0;
float balance =0, charges =0, credits =0, credit_limit =0;
float sum =0;
while (account != -1)
{
printf ("lease enter account number:"
scanf ("%d", &account);
printf ("lease enter beginning balance:"
scanf ("%f", &balance);
printf ("lease enter total charges:"
scanf ("%f", &charges);
printf ("lease enter total credits:"
scanf ("%f", &credits);
printf ("lease enter credit limit:"
scanf ("%f", &credit_limit);
sum =balance + charges -credits;
if (sum >; credit_limit)
{
printf ("ACCOUNT NUMBER:%d\n", account);
printf ("CREDIT LIMIT :%.2f\n", credit_limit);
printf ("NEW LIMIT :%.2f\n", sum);
printf ("Credit limit exceed !\n"
}
}
}
上述代码都能正常运行。但唯一的缺点就是退出while结构时,就不正常拉。
我的意思时想在第一句:
printf ("lease enter account number:" 这个退出循环。
但每次要把五条语句都是分别输入-1 时,才会推出,而且会把-1 在程序里面计算
并且打印出结果.
请各位大哥们,帮帮我,这时什么缘故,谢谢? |
|