標題:
switch 判斷式 (二)
[打印本頁]
作者:
tonyh
時間:
2013-10-19 17:23
標題:
switch 判斷式 (二)
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int answer;
cout<<"<小米的腦殘問答>"<<endl;
cout<<"請問豬有幾隻腳? (1)一隻 (2)兩隻 (3)三隻 (4)四隻"<<endl;
cout<<"請作答: ";
cin>>answer;
switch(answer)
{
case 1:
cout<<"用跳的嗎?";
break;
case 2:
cout<<"沒吃過豬肉也看過豬走路!";
break;
case 3:
cout<<"你是豬啊?";
break;
case 4:
cout<<"答對了!";
break;
default:
cout<<"輸入錯誤!";
}
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
張郁庭
時間:
2013-10-19 17:26
#include <iostream>
#include <cstdlib>
using namespace std;
int main ()
{
int score,level;
cout << "請輸入您的成績:";
cin >> score;
level = score/10;
switch (level)
{
case 10:
case 9:
case 8:
cout << " 恭喜你! ";
break;
case 7:
cout << " 多複習點吧!" ;
break;
case 6:
cout << " 你上課有在專心聽嗎? ";
break;
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:
cout << " 回家等著被罵吧! ";
break;
default:
cout << " 輸入錯誤! ";
}
cout << endl;
system("pause");
return 0;
}
複製代碼
作者:
施伯叡
時間:
2013-10-19 17:29
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int ans;
cout << "超智障問答" <<endl;
cout << "請問水是甚麼顏色?" ;
cout << "(1)黃色 (2)紅色 (3)透明 (4)紫色" << endl;
cout << "請作答:" ;
cin >> ans ;
switch(ans)
{
case 1:
cout<<"去測一下你的智商吧!";
break;
case 2:
cout<<"犯案現場請勿靠近!";
break;
case 3:
cout<<"你的智商180!";
break;
case 4:
cout<<"你喝水溝的水嗎?";
break;
default:
cout<<"別亂打!";
}
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
張郁偵
時間:
2013-10-19 17:33
#include <iostream>
#include <cstdlib>
using namespace std;
int main ()
{
int answer;
cout<<" 一, 選擇題"<<endl;
cout<<"請問豬的運動型態為何? (1)飛(2)爬(3)走(4)以上全部正確"<<endl;
cin >>answer;
switch(answer)
{
case 1:
cout<<"你有看過豬長翅膀的嗎?"<<endl;
break;
case 2:
cout<<"豬不是昆蟲!"<<endl;
break;
case 3:
cout<<"賓果!!"<<endl;
break;
case 4:
cout<<"瞎!"<<endl;
break;
default:
cout<<"輸入錯誤"<<endl;
}
system ("pause");
return 0;
}
複製代碼
作者:
劉得旗
時間:
2013-10-19 17:33
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int answer;
cout<<"<腦殘問答>"<<endl;
cout<<"請問你有幾隻手? (1)1隻 (2)5隻 (3)2隻 (4)9隻"<<endl;
cin>>answer;
switch(answer)
{
case 1:
cout<<"笨蛋";
break;
case 2:
cout<<"笨蛋";
break;
case 3:
cout<<"答對了!阿不就好棒棒?";
break;
case 4:
cout<<"笨蛋";
break;
default:
cout<<"Error";
}
system("pause");
return 0;
}
複製代碼
作者:
張彥承
時間:
2013-10-19 17:38
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int answer;
cout<<"<Smosh's stupid question>"<<endl;
cout<<"2個半小時是幾分鐘:(1)120分(2)60分(3)55分(4)59分"<< endl;
cout<<"Please answer:"<<endl;
cin>>answer;
switch(answer)
{
case 1:
cout<<"wrong answer!"<<endl;
break;
case 2:
cout<<"Bingo!"<<endl;
break;
case 3:
cout<<"wrong answer!"<<endl;
break;
case 4:
cout<<"wrong answer!"<<endl;
break;
default:
cout<<"you really are a dickhole!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
張峻瑋
時間:
2013-10-19 17:38
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int answer;
cout<<"<超腦殘問答>"<<endl;
cout<<"雞有幾顆頭?(1)1顆(2)2顆(3)3顆(4)無限多顆"<<endl;
cout<<"請作答!!!";
cin>>answer;
switch(answer)
{
case 1:
cout<<"答對了!!好厲害!";
break;
case 2:
cout<<"智商-10000000000";
break;
case 3:
cout<<"恐怖啊!";
break;
case 4:
cout<<"慘了!雞變成了怪物";
break;
default:
cout<<"輸入錯誤!";
}
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
周雍程
時間:
2013-10-19 17:40
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int answer;
cout <<"<???>"<<endl;
cout <<"你晚上吃什麼? (1)垃圾 (2)鋼鐵 (3)我 (4)沒有吃東西"<<endl;
cout <<"請作答:";
cin >> answer;
switch(answer)
{
case 1:
cout <<"你是流浪漢嗎?"<<endl;
break ;
case 2:
cout <<"嗨!鋼鐵人"<<endl;
break ;
case 3:
cout <<"回家吃自己!"<<endl;
break ;
case 4:
cout <<"你失憶了,走!去看醫生."<<endl;
break ;
default:
cout <<"不會數數嗎,只有4而已!!"<<endl;
}
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2