標題:
switch 判斷式
[打印本頁]
作者:
tonyh
時間:
2012-8-8 09:21
標題:
switch 判斷式
#include<iostream>
using namespace std;
int main()
{
int score, level;
cout<<"請輸入你的分數: ";
cin>>score;
level=score/10;
switch(level) //針對 level 做判斷
{
case 10:
case 9:
cout<<"得 A !"<<endl;
break;
case 8:
cout<<"得 B !"<<endl;
break;
case 7:
cout<<"得 C !"<<endl;
break;
case 6:
cout<<"得 D !"<<endl;
break;
default: //其他所有狀況
cout<<"不及格!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
t2364705
時間:
2012-8-8 09:25
#include<iostream>
using namespace std;
int main()
{
int score;
int level;
cout<<"請輸入您的分數: ";
cin>>score;
level=score/10;
switch(level)
{
case 10:
case 9:
cout<<"得 A !"<<endl;
break;
case 8:
cout<<"得 B !"<<endl;
break;
case 7:
cout<<"得 C !"<<endl;
break;
case 6:
cout<<"得 D !"<<endl;
break;
default:
cout<<"得 E !不 及 格!"<<endl;
break;
}
system("pause");
return 0;
}
複製代碼
作者:
周旻賢
時間:
2012-8-8 09:31
#include<iostream>
using namespace std;
int main()
{
int score, level;
cout<<"請輸入您的分數: "<<endl;
cin>>score;
level=score/10;
switch(level)
{
case10:
cout<<"A++,繼續保持!!!"<<endl;
break;
case9:
cout<<"A,目標A++ !"<<endl;
break;
case8:
cout<<"B 別掉下去了!孩子!"<<endl;
break;
case7:
cout<<"c 你肯定在混"<<endl;
break;
case6:
cout<<"D 竹筍炒肉絲的味道應該不錯要不要來一盤?!"<<endl;
break;
default:
cout<<"F 來人阿!關進地牢,三天後問審!!!!!!!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
蔡昀佑
時間:
2012-8-8 09:35
#include<iostream>
using namespace std;
int main()
{
int score, level;
cout<<"請輸入您的分數: ";
cin>>score;
level=score/10;
switch(level)
{
case 10:
case 9:
cout<<"A級 !"<<endl;
break;
case 8:
cout<<"B級 !"<<endl;
break;
case 7:
cout<<"C級 !"<<endl;
break;
case 6:
cout<<"D級 !"<<endl;
break;
default:
cout<<"不及格!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
劉嘉琳
時間:
2012-8-8 09:38
#include<iostream>
using namespace std;
int main()
{
int score;
int level;
cout<<"請輸入你的分數: ";
cin>>score;
level=score/10;
switch(level)
{
case 10:
case 9:
cout<<"哇!!很好很好!!NO.1喔~"<<endl;
break;
case 8:
cout<<"維持下去!!第一名離你不遠了NO.2~"<<endl;
break;
case 7:
cout<<"多讀一點書啦NO.3!!"<<endl;
break;
case 6:
cout<<"偷懶不讀書!!NO.4"<<endl;
break;
default:
cout<<"你乾脆不要寫~最後第一名!!!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
周煒翔
時間:
2012-8-8 09:39
#include<iostream>
using namespace std;
int main()
{
int score, level;
cout<<"請輸入您的分數:";
cin>>score;
level=score/10;
switch(level)
{
case 10:
case 9:
cout<<"得A"<<endl;
break;
case 8:
cout<<"得B"<<endl;
break;
case 7:
cout<<"得C"<<endl;
break;
case 6:
cout<<"得D"<<endl;
break;
default:
cout<<"不及格"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
劉泳鱔
時間:
2012-8-8 09:42
#include<iostream>
using namespace std;
int main()
{
int score, level;
cout<<"請輸入您的分數:";
cin>>score;
level=score/10;
switch(level)
{
case 10:
case 9 :
cout<<"得A"<<endl;
break;
case 8 :
cout<<"得B"<<endl;
break;
case 7 :
cout<<"得C"<<endl;
break;
case 6 :
cout<<"得D"<<endl;
break;
default:
cout<<"得E(不及格)"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
許睿森
時間:
2012-8-8 09:42
#include<iostream>
using namespace std;
int main()
{
string n;
cout<<"請輸入你的名子:" ;
cin>>n;
int x, y;
cout<<"請輸入你的分數:";
cin>>x;
y=x/10;
switch(y)
{
case 10:
cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆" <<endl ;
cout<<"☆恭喜"<<"n"<<"得到A++,滿分了喔!☆" <<endl ;
cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆" <<endl ;
break;
case 9:
cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆" <<endl ;
cout<<"☆恭喜"<<"n"<<"得到A,加油滿分一定是你的!☆" <<endl ;
cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆" <<endl ;
break;
case 8:
cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆" <<endl ;
cout<<"☆恭喜"<<"n"<<"得到A-,可以再加油一點喔!☆" <<endl ;
cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆" <<endl ;
break;
case 7:
cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆" <<endl ;
cout<<"☆恭喜"<<"n"<<"得到B,不夠認真阿!☆" <<endl ;
cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆" <<endl ;
break;
case 6:
cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆" <<endl ;
cout<<"☆恭喜"<<"n"<<"得到C,不行!不行!你這樣一定會不及格的加油一點阿!☆" <<endl ;
cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆" <<endl ;
break;
default:
cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆" <<endl ;
cout<<"☆"<<"n"<<"獲得D!!!給我回去重考一百次再回來!!☆" <<endl ;
cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆" <<endl ;
break;
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2