標題:
switch 判斷式
[打印本頁]
作者:
tonyh
時間:
2013-3-23 14:05
標題:
switch 判斷式
本帖最後由 tonyh 於 2013-3-23 14:53 編輯
成績分級程式
90分~100分 優
80分~89分 甲
70分~79分 乙
60分~69分 丙
0分~59分 丁
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score, level;
cout<<"請輸入你的成績: ";
cin>>score;
level=score/10;
switch(level) //針對level做切換
{
case 10: case 9:
cout<<"優!"<<endl;
break;
case 8:
cout<<"甲!"<<endl;
break;
case 7:
cout<<"乙!"<<endl;
break;
case 6:
cout<<"丙!"<<endl;
break;
case 5: case 4: case 3: case 2: case 1: case 0:
cout<<"丁!"<<endl;
break;
default:
cout<<"輸入錯誤!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
劉得旗
時間:
2013-3-23 14:38
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score, level;
cout<<"entre your score: ";
cin>> score;
level=score/10;
switch(level)
{
case 10: case 9:
cout<<"優"<<endl;
break;
case 8:
cout<<"甲"<<endl;
break;
case 7:
cout<<"乙"<<endl;
break;
case 6:
cout<<"丙"<<endl;
break;
case 5: case 4: case 3: case 2: case 1: case 0:
cout<<"丁"<<endl;
break;
default:
cout<<"Error"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
黃崇維
時間:
2013-3-23 14:43
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score,level;
cout<<"請輸入你的成績:";
cin>>score;
level=score/10;
switch(level)
{
case 10:
case 9:
cout<<"優!稀奇!"<<endl;
break;
case 8:
cout<<"甲!屌爆了!"<<endl;
break;
case 7:
cout<<"乙!不錯喔!"<<endl;
break;
case 6:
cout<<"丙!厲害!"<<endl;
break;
case 5: case 4: case 3: case 2: case 1: case 0:
cout<<"丁!值得鼓勵!"<<endl;
break;
default:
cout<<"輸入錯誤!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
林以諾
時間:
2013-3-23 14:43
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score,level;
cout<<"請輸入你的分數:";
cin>>score;
level=score/10;
switch(level)
{
case 10:
case 9:
cout<<"優!"<<endl;
break;
case 8:
cout<<"甲!"<<endl;
break;
case 7:
cout<<"乙!"<<endl;
break;
case 6:
cout<<"丙!"<<endl;
break;
case 5:case 4:case 3:case 2:case 1:case 0:
cout<<"丁!"<<endl;
break;
default:
cout<<"輸入錯誤!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
劉泳鱔
時間:
2013-3-23 14:43
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score, level;
cout<<"請輸入你的分數"<<endl;
cin>>score;
level=score/10;
switch(level)
{
case 10: case 9:
cout<<"優!"<<endl;
break;
case 8:
cout<<"甲!"<<endl;
break;
case 7:
cout<<"乙!"<<endl;
break;
case 6:
cout<<"丙!"<<endl;;
break;
case 5: case 4: case 3: case 2: case 1: case 0:
cout<<"丁!"<<endl;
break;
default:
cout<<"輸入錯誤!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
許逸群
時間:
2013-3-23 14:48
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score,level;
cout<<"請輸入您的分數: ";
cin>>score;
level=score/10;
switch(level)
{
case 10: case 9:
cout<<"優"<<endl;
break;
case 8:
cout<<"甲"<<endl;
break;
case 7:
cout<<"乙"<<endl;
break;
case 6:
cout<<"丙"<<endl;
break;
case 5: case 4: case 3: case 2: case 1: case 0:
cout<<"丁"<<endl;
break ;
default:
cout<<"輸入錯誤"<<endl;
}
system ("pause");
return 0;
複製代碼
作者:
黃柏維
時間:
2013-3-23 14:49
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score,level;
cout<<"請輸入你的成績: ";
cin>>score;
level=score/10;
switch(level)
{
case 10:case 9:
cout<<"優"<<endl;
break;
case 8:
cout<<"甲"<<endl;
break;
case 7:
cout<<"乙"<<endl;
break;
case 6:
cout<<"丙"<<endl;
break;
case 5:case 4:case 3:case 2:case 1:case 0:
cout<<"丁"<<endl;
break;
default:
cout<<"輸入錯誤"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
蘇昱安
時間:
2013-3-23 14:54
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score,level;
cout<<"請輸入你的分數";
cin>>score;
level=score/10;
switch(level)
{
case 10:
case 9:
cout<<"優!"<<endl;
break;
case 8:
cout<<"甲!"<<endl;
break;
case 7:
cout<<"乙!"<<endl;
break;
case 6:
cout<<"丙!"<<endl;
break;
case 5: case 4: case 3: case 2: case 1: case 0:
cout<<"丁!"<<endl;
break;
default:
cout<<"輸入錯誤!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
林鎧言
時間:
2013-3-23 14:56
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int s ,level;
cout<<"請輸入你的分數:";
cin>>s;
level=s/10;
switch(level)
{
case 10: case 9:
cout<<"優!"<<endl;
break;
case 8:
cout<<"甲!"<<endl;
break;
case 7:
cout<<"乙!"<<endl;
break;
case 6:
cout<<"丙!"<<endl;
break;
case 5: case 4:case 3:case 2: case 1: case 0:
cout<<"丁!"<<endl;
break;
default:
cout<<"輸入錯誤"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
郭凡瑛
時間:
2013-3-28 20:52
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score , level;
cout<<"請輸入成績:";
cin>>score;
level=score/10;
switch(level)
{
case 10:
case 9:
cout<<"優"<<endl;
break;
case 8:
cout<<"甲"<<endl;
break;
case 7:
cout<<"乙"<<endl;
break;
case 6:
cout<<"丙"<<endl;
break;
case 5: case 4: case 3: case 2: case 1:
cout<<"丁"<<endl;
break;
default:
cout<<"輸入錯誤!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
張瀚仁
時間:
2013-3-28 20:55
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score, level;
cout<<"請輸入你的成績: ";
cin>>score;
level=score/10;
switch(level)
{
case 10: case 9:
cout<<"優!"<<endl;
break;
case 8:
cout<<"甲!"<<endl;
break;
case 7:
cout<<"乙!"<<endl;
break;
case 6:
cout<<"丙!"<<endl;
break;
case 5: case 4: case 3: case 2: case 1: case 0:
cout<<"丁!"<<endl;
break;
default:
cout<<"輸入錯誤!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
林長逸
時間:
2013-3-29 18:14
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score, level;
cout<<"請輸入你的成績:(只能輸入0-100之間的數字)";
cin>>score;
level=score/10;
switch(level)
{
case 10: case 9:
cout<<"優!"<<endl;
break;
case 8:
cout<<"甲!"<<endl;
break;
case 7:
cout<<"乙!"<<endl;
break;
case 6:
cout<<"丙!"<<endl;
break;
case 5: case 4: case 3: case 2: case 1: case 0:
cout<<"丁!"<<endl;
break;
default:
cout<<"輸入錯誤!"<<endl;
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2