智慧职教: 根据温度判断舒适度,温度大于等于30度炎热,在20~30之间稍热,在10~20度之间舒适,10度以下寒冷。程序空白处应填写______. #include
void main( ){doubletemp; scanf("%lf",&temp);if (temp>=30) printf("炎热
"); else if ()printf("稍热
"); elseif(temp>=10)printf("舒适
");elseprintf("寒冷
")}
void main( ){doubletemp; scanf("%lf",&temp);if (temp>=30) printf("炎热
"); else if ()printf("稍热
"); elseif(temp>=10)printf("舒适
");elseprintf("寒冷
")}
举一反三
- 有以下程序 #include main() { int x; scanf("%d",&x); if(x>10) printf("1"); else if(x>20) printf("2"); else if(x>30) printf("3"); } 若运行时输入:35,则输出结果是
- 写出下列程序运行结果 #include “stdio.h” void swap(int *px , int *py ); void main() { int a,b; a=5; b=10; printf(“ before swap a=%d, b=%d ”,a,b); swap(&a,&b); printf(“after swap a=%d, b=%d ”,a,b); } voidswap(int *px , int *py ) { int temp; temp=*px; *px=* py; *py=temp; printf(“ in swap x=%d,y=%d ”,*px, *py); }
- 输入5个字符串,将其中最小的打印出来 #include “stdio.h” #include “string.h” main() { char str[10],temp[10]; int i; (1) ; for(i=0;i<4;i++) { gets(str); if(strcmp(temp,str)>0) (2) ; } printf(“ The first string is:%s ”,temp); }
- 下面的程序是将array数组按从小到大进行排序,请填空。 #include<stdio.h> int main() { int array[10]; int i,j,temp; printf("input 10 numbers please "); for(i=0;i<10;i++) scanf("%d",&array[i]); for(i=0;i<9;i++) for(j=i+1;j<10;j++) if() { temp=array[i]; array[i]=array[j]; array[j]=temp; } printf("the sorted 10 numbers: "); for(i=0;i<10;i++) printf("%d ",array[i]); return 0; }[/i][/i][/i][/i]
- 有以下程序段:#include int main(){int x[ ] = {10, 20, 30}; int *px = x;printf("%d, ", ++*px); printf("%d, ", *px); px = x;printf("%d, ", (*px)++); printf("%d, ", *px); px = x;printf("%d, ", *px++); printf("%d, ", *px); px = x;printf("%d, ", *++px); printf("%d\n", *px);return 0;}程序运行后的输出结果是( ) A: 20, 10, 11, 10, 11, 10, 11, 10 B: 11, 11, 11, 12, 12, 20, 20, 20 C: 20, 10, 11, 20, 11, 12, 20, 20 D: 11, 11, 11, 12, 12, 13, 20, 20