从键盘输入一个数给浮点型变量x,然后输出该数的绝对值y。
#include "stdio.h"
main()
{ float x,y;
scanf("%f", (1) );
if(x<0) y=-x;
(2) y=x;
printf("%f\n", y);
}
#include "stdio.h"
main()
{ float x,y;
scanf("%f", (1) );
if(x<0) y=-x;
(2) y=x;
printf("%f\n", y);
}
举一反三
- 从键盘输入一个数给浮点型变量x,然后用双分支if语句求出x的绝对值y,最后输出y的值。 #include "stdio.h" int main() { float x,y; scanf("%f", &x); if(x>=0) (1) ; (2) y=-x; printf("%f\n", y); }
- *【程序填空】题目:从键盘上输入一个数x,输出该数的绝对值。*/ #include "stdio.h" /***********SPACE***********/ 【?】 main() { /***********SPACE***********/ 【?】 x,y; /***********SPACE***********/ scanf("%f",【?】); /***********SPACE***********/ y=fabs(【?】); printf("%f\n",y); }
- 以下程序运行时从键盘输入3.6,2.4,输出结果是。 #include void main() { float x,y,z; scanf("%f,%f",&x,&y); z=x/y; while(1) { if(fabs(z)>1.0) { x=y; y=x; z=x/y; } else break; } printf("%f",y); }
- 以下程序没有语法问题的是() A: B: include<;stdio.h>;int main( ){int x , y = 5 ; printf( "%d\n" , x / y ) ; return 0 ;} C: D: include<;stdio.h>;int main( ){int x = 3 ;y = 5 ; printf( "%d\n" , x / y ) ; return 0 ;} E: F: include<;stdio.h>;int main( ){int x = 3 ,y ; printf( "%d\n" , x / y ) ;y = 5; return 0 ;} G: H: include<;stdio.h>;int main( ){int x = 3 , y = 5 ; printf( "%d\n" , x / y ) ; return 0 ;}
- 从键盘输入一个数给浮点型变量x,然后用双分支if语句求出x的绝对值y,最后输出y...printf("%f", y);}