合法输入和非法输入
程序代码:
#include<stdio.h> #include<math.h> main() { double a=0.0; int b; double c; printf("This project is used to separate the integer and decimal part of a number\n"); printf("please input the number:\n"); scanf("%lf",&a); if (a>=0.0) { b=(int)floor(a); printf("the integer of the number you input is %d\n",b); } else if(a<0.0) { b=(int)ceil(a); printf("the integer of the number you input is %d\n",b); } else printf("Please check the number you input"); c=a-b; printf("the decimal part of the number you input is %g\n",c); return 0; }哪位高手看看第二十八和二十九行该怎么写,谢谢了
[ 本帖最后由 ychf890225 于 2010-4-22 13:21 编辑 ]