回复 9楼 御坂美琴
没法终止循环啊
这是结合前面几位修改的楼主试下
#include<stdio.h>
#include<math.h>
int main()
{
float num ;
int integer_num = -1;
int decimal_num = 0;
while(num!=0)
{
scanf("%f", &num);
if(fabs(num - (int)num) > 1e-4)
{
decimal_num=decimal_num+1;
}
else
integer_num=integer_num+1;
}
printf("the integer_num is %d\n", integer_num);
printf("the decimal_num is %d\n", decimal_num);
return 0;
}