读程序题:在空白处填写正确的代码,实现分段函数:x<0y=2x+3;x=0y=0;x>0y=(x+7)/3;输入x,计算y值,输出y。voidmain(){intx,y;scanf(“%d”,&x);if(x<0)y=2*x+3;______y=0;if(x>0)y=(x+7)/3;printf(“%d”,y);}
查看答案
编程题:输入一个整型变量num,判断num是否为偶数,为偶数则输出num值。
读程序,写出运行结果。#include main( ){ int a=1,b=0;scanf("%d",&a);switch(a){case 1: b=1;printf("b=%d ,", b);case 2: b=2;printf("b=%d ,", b);case 3: b=3;printf("b=%d ,", b);break;default : b=10;printf("b=%d ,", b); }}若键盘输入2,运运行结果为:_________________
读程序题:#include main(){ float a,b,c,t; a=3; b=7; c=1;if(a>b) {t=a;a=b;b=t;}if(a>c) {t=a;a=c;c=t;}if(b>c) {t=b;b=c;c=t;}printf("%5.2f,%5.2f,%5.2f",a,b,c);}
#include < stdio .h >void main ( ){ float c=3.0 , d=4.0;if ( c>d ) c=5.0;elseif ( c==d ) c=6.0;else c=7.0;printf ( “%.1f\n”,c ) ;}运行结果为_____________________