參考回應
A or a: 用跳的嗎?
B or b: 沒吃過豬肉也看過豬走路!
C or c: 你是豬啊?
D or d: 答對了!
其他: 輸入錯誤!
#include<cstdlib>
#include<iostream>
using namespace std;
int main()
{
char ans; //宣告字元
cout<<"<小米的腦殘問答>"<<endl;
cout<<"請問豬有幾隻腳? (A)一隻 (B)兩隻 (C)三隻 (D)四隻"<<endl;
cout<<"請作答: ";
cin>>ans;
switch(ans)
{
case 'a':
case 'A':
cout<<"用跳的嗎?";
break;
case 'b':
case 'B':
cout<<"沒吃過豬肉也看過豬走路!";
break;
case 'c':
case 'C':
cout<<"你是豬啊!";
break;
case 'd':
case 'D':
cout<<"答對囉!";
break;
default:
cout<<"輸入錯誤!";
}
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者: 高湘庭 時間: 2024-6-8 15:45
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
char x;
cout<<"<小米的腦殘問答>"<<endl;
re:
cout<<"請問豬有幾隻腳?<A>一隻<B>兩隻<C>三隻<D>四隻"<<endl;
cin>>x;
switch(x)
{case 'A':
case 'a':
cout<<"用跳的嗎?"<<endl;
break;
case 'B':
case 'b':
cout<<"沒吃過豬也看過豬走路!"<<endl;
break;
case 'C':
case 'c':
cout<<"你是豬啊?"<<endl;
break;
case 'D':
case 'd':
cout<<"答對了"<<endl;
break;
default:
cout<<"輸入錯誤"<<endl;
break;
system ("pause");
return 0;
}
goto re;
}作者: 李偈睿 時間: 2024-6-8 15:53
本帖最後由 李偈睿 於 2024-6-8 15:54 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
char ans;
cout<<"<小米的腦殘問答>"<<endl;
re:
cout<<"請問豬有幾隻腳?(A)一隻(B)兩隻(C)三隻(D)四隻"<<endl;
cin>>ans;
switch(ans)
{
case 'a':
case 'A':
cout<<"用跳的嗎?"<<endl;
break;
case 'b':
case 'B':
cout<<"沒吃過豬肉也看過豬走路!"<<endl;
break;
case 'c':
case 'C':
cout<<"你是豬嗎?"<<endl;
break;
case 'd':
case 'D':
cout<<"回答正確"<<endl;
break;
default:
cout<<"輸入錯誤"<<endl;
}
cout<<endl;
goto re;
system("pause");
return 0;
}
複製代碼
作者: 林少謙 時間: 2024-6-8 15:53
#include <cstdlib>
using namespace std;
int main()
{
cout<<"<腦殘問答>"<<endl;
re:
char x;
cout<<"請問豬有幾隻腳?<A>一隻<B>兩隻<C>三隻<D>四隻"<<endl;
cout<<"請作答:";
cin>>x;
switch (x)
{
case 'a':
case 'A':
cout<<"用跳的嗎?"<<endl;
break;
case 'b':
case 'B':
cout<<"沒吃過豬肉也看過豬走路!"<<endl;
break;
case 'c':
case 'C':
cout<<"你是豬?"<<endl;
break;
case 'd':
case 'D':
cout<<"恭喜答對"<<endl;
break;
default:
cout<<"沒這選項 重選"<<endl;
}
cout<<endl;
goto re;
system("pause");
return 0;
}作者: 洪榮辰 時間: 2024-6-8 15:53
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
char ans;
cout<<"<小米的腦殘問題>"<<endl;
cout<<"請問豬有幾隻腳? (A)一隻(B)二隻(C)三隻(D)四隻"<<endl;
cout<<"請作答:";
cin>>ans;
switch(ans)
{
case 'A':
case 'a':
cout<<"用跳的嗎?"<<endl;
break;
case 'B':
case 'b':
cout<<"沒吃過豬肉也看過豬走路!"<<endl;
break;
case 'C':
case 'c':
cout<<"你是豬啊?"<<endl;
break;
case 'D':
case 'd':
cout<<"答對了!"<<endl;
break;
default:
cout<<"輸入錯誤!"<<endl;
}
cout<<endl;
goto re;
system("pause");
return 0;
}
複製代碼
作者: 陳俞安 時間: 2024-6-8 15:55
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
re:
char option;
cout<<"請問豬有幾隻腳?(A)一隻;(B)兩隻;(C)三隻;(D)四隻"<<endl;
cin>>option;
switch(option){
case 'A':
case 'a':
cout<<"用跳的嗎?"<<endl;
goto re;
break;
case 'B':
case 'b':
cout<<"沒吃過豬肉也看過豬走路!"<<endl;
goto re;
break;
case 'C':
case 'c':
cout<<"你是豬啊?"<<endl;
goto re;
break;
case 'D':
case 'd':
cout<<"答對了"<<endl;
break;
default:
cout<<"輸入錯誤"<<endl;
goto re;
}
return 0;
}作者: 劉奕劭 時間: 2024-6-8 15:56
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
char ans;
re:
cout<<"小米的腦殘問答!"<<endl;
cout<<"請問豬有幾隻腳?(A)一隻(B)兩隻(C)三隻(D)四隻"<<endl;
cout<<"請作答!";
cin>>ans;
switch(ans)
{
case 'A':
case 'a':
cout<<"用跳的嗎?"<<endl;
break;
case 'B':
case 'b':
cout<<"沒吃過豬肉也看過豬走路!"<<endl;
break;
case 'C':
case 'c':
cout<<"你是豬啊?"<<endl;
break;
case 'D':
case 'd':
cout<<"答對了!"<<endl;
break;
default:
cout<<"輸入錯誤!"<<endl;
break;
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
char ans;
re:
cout<<"請問豬有幾隻腳?(A)一隻(B)二隻(C)三隻(D)四隻"<<endl;
cin>>ans;
switch(ans){
case 'a':
case 'A':
cout<<"用跳的嗎?"<<endl;
break;
case 'b':
case 'B':
cout<<"沒吃過豬肉也看過豬走路!"<<endl;
break;
case 'c':
case 'C':
cout<<"你是豬啊?"<<endl;
break;
case 'd':
case 'D':
cout<<"正確"<<endl;
break;
default:
cout<<"輸入錯誤"<<endl;
break;
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
char answer;
cout<<"<小米的腦殘問答>"<<endl;
cout<<"請問豬有幾隻腳?<A>1隻?<B>2隻<C>3隻<D>4隻"<<endl;
re:
cout<<"請作答";
cin>>answer;
switch(answer){
case 'A':
case 'a':
cout<<"用跳的嗎?"<<endl;
break;
case 'B':
case 'b':
cout<<"沒吃過豬也看過豬走路"<<endl;
break;
case 'C':
case 'c':
cout<<"你是豬啊?"<<endl;
break;
case 'D':
case 'd':
cout<<"答對了!"<<endl;
break;
default:
cout<<"輸入錯誤"<<endl;
break;