scanf连续输入字符,中间不要忘记\n
1 #include <stdio.h> 2 3 int main(void) 4 5 { 6 7 int precipitating; 8 9 int temperature; 10 11 printf("\nInput precipitating"); 12 13 scanf("%d",&precipitating); 14 printf("\nInput temperature"); 15 scanf("\n%d",&temperature);
//When continuous input chars by sacnf ,remember add \n 16 17 18 if (precipitating) 19 20 { 21 22 if (temperature<32) 23 24 printf("snowing\n"); 25 26 else 27 28 printf("raining\n"); 29 30 31 32 } 33 34 else 35 36 { 37 if (temperature<60) 38 39 printf("cold\n"); 40 41 else 42 43 printf("warm\n"); 44 45 } 46 47 return 0; 48 49 }
posted on 2018-02-26 22:03 yiludaifei 阅读(349) 评论(0) 收藏 举报
浙公网安备 33010602011771号