用switch語句實現程式 輸入學生的兩門課成績

2022-01-29 00:36:38 字數 1423 閱讀 4805

1樓:倒黴熊

else if (z>=160 || z<180)s=c;

else if (z>=140 || z<160)s=d;

else if (z>=120 || z<140)這裡三個 || 應該是 &&吧 ?是大於等於160且小於180 而不是或吧

2.exe這個程式你關閉了嗎??到工作管理員中看看,如果沒有關閉 先把這個程式結束掉

2樓:匿名使用者

我幫你把程式改了下:改了兩處地方

留意#include

using namespace std;

void main()

}除錯過了 可以的!

如果出現你那種錯誤 基本是你執行過一會 然後那個dos視窗沒關掉有執行第二回!關了試試!

3樓:

#include

using namespace std;

void main()

}你的四個else if中的邏輯運算子||(條件或)用錯了,應該用條件與&&,如果用或的話你那幾個條件就沒有意義了,然後變數s是char型的,對他們賦值要加單引號,如s='a'

4樓:喜歡不是愛

void main()

temp=yu+shu;

if(temp%180>=0 && (temp/180)==1)else if( (temp%160) >=0 && (temp%160)<20 && (temp/160)==1 )

else if(( (temp%140) >=0 && (temp%140)<20 ) &&(temp/140)==1)

else if(( (temp%120) >=0 && (temp%120)<20 )&&(temp/120)==1)

else

switch(temp)}

編一個程式,輸入0—100之間的一個學生成績分數,用switch語句輸出成績等

5樓:匿名使用者

int level; // 成績等級

botton = int.parse(console.readline());

if(botton<60) level=3; //60分以下不及格else if(botton>=80) level=1; //80分以上優秀

else level=2;  // 60-80分為及格switch (level)

6樓:匿名使用者

using system;

using system.collections.generic;

using system.linq;

using system.text;

namespace hello_worldconsole.readkey();}}}

用if和switch語句編寫c語言程式

include int main switch的 include int main puts s return 0 c語言,分別用if 語句和switch語句編寫程式求分段函式的值 if語句 inlcude include define a 10 a自己取值 void main switch語句 i...

if語句和switch語句在構成分支程式上各有什麼特點

一個最大的特點就是 如果你的條件判斷非常多,你用if.elseif.else這樣的判斷,將變專得很難閱讀。而屬如果使用switch,則變得簡單易懂。如果只有很少的幾個條件判斷,則沒什麼區別了 當然其語法上是有些區別的 if語句在用分支的時候,自由性大點,條件 可以寫一個範圍也可也是一個表示式回 而s...

用switch語句程式設計設計簡單的計算器程式,要求根據使用者從鍵盤輸入的表示式

include includemain printf doyouwanttocontinue y nory n fflush stdin 這是清掉之前的回車鍵用的 while toupper getchar y 你的底這樣好這個應該沒有問題了吧。include include int main el...