判斷方法:1、用「switch(成績/10){case 9:A;..case 6:D;default:E;}」語句;2、用「if(成績>= 90)A;else if(成績>=80)B;..else if(成績>=60)D;elseE;”語句。
本教學操作環境:windows7系統、c99版本、Dell G3電腦。
分析:我們既可以使用else if來進行判斷也可以使用switch case來進行判斷。
主題要求如下:輸入學生成績,自動判斷等級
#成績 | 等級 |
---|---|
#90 | |
80 | |
70 | |
##60D等級 |
使用else if語句
1、使用switch…case語句判斷等級
##include
##2、使用if..else..if語句
#includeint main() { int score; scanf("%d",&score); if(score>=90)printf("A"); else if(score>=80)printf("B"); else if(score>=70)printf("C"); else if(score>=60)printf("D"); else printf("E"); return 0; }
以上是c語言輸入成績怎麼判斷等級的詳細內容。更多資訊請關注PHP中文網其他相關文章!