標題:
if...else if...else 判斷式
[打印本頁]
作者:
tonyh
時間:
2016-3-19 10:31
標題:
if...else if...else 判斷式
本帖最後由 tonyh 於 2016-3-19 11:36 編輯
[attach]1570[/attach]
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score; //變數名稱與要做的事有一定程度的相關
re:
cout<<"請輸入你的成績: ";
cin>>score;
if(score==100) //在判斷兩邊的值是否相等,要用雙等號
cout<<"哇!滿分!"<<endl;
else if(score<100 && score>=60)
cout<<"恭喜你及格了,給你糖吃!"<<endl;
else if(score<60 && score>0)
cout<<"不及格!打屁股!"<<endl;
else if(score==0)
cout<<"零分?斬!"<<endl;
else
cout<<"輸入錯誤!斬!"<<endl;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
黃茂勛
時間:
2016-3-19 11:29
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
int score;
cout<<"請輸入你的成績: ";
cin>>score;
if(score==100)
cout<<"哇!滿分!"<<endl;
else if(score<100 && score>=60)
cout<<"恭喜你及格了!"<<endl;
else if(score<60 && score>0)
cout<<"不及格!白癡!"<<endl;
else if(score==0)
cout<<"零分?回家吃狗屎吧!"<<endl;
else
cout<<"輸入錯誤?你腦袋有問題?"<<endl;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
陸長辰
時間:
2016-3-19 11:30
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
cout<<"請輸入你的成績:";
cin>>score;
if(score==100)
cout<<"滿分"<<endl;
else if(score<100&&score>=60)
cout<<"恭喜你及格"<<endl;
else if(score<60&&score>0)
cout<<"恭喜你不及格"<<endl;
else if(score==0)
cout<<"零分,超棒的!!!!!"<<endl;
else
cout<<"輸入錯誤,超棒的!!!!!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
任立宇
時間:
2016-3-19 11:30
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
cout<<"成績"<<endl
cin>>score;
if(score==100)
cout<<"好棒棒"<<endl
else if(score<100 && score>=60)
cout<<"及格"<<endl
else if(score<60 && score>=0)
cout<<"廢物"<<endl
else if(score=0)
cout<<"廢物"<<endl
syatam()
return 0;
}
複製代碼
作者:
張孟軒
時間:
2016-3-19 11:31
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
re:
cout<<"請輸入你的成績:"<<endl;
cin>>score;
if(score==100)
cout<<"哇!滿分! "<<endl;
else if(score<100 && score>=60)
cout<<"恭喜及格!"<<endl;
else if(score<60 && score>0)
cout<<"不及格,打屁股"<<endl;
else if(score==0)
cout<<"零分?斬!"<<endl;
else
cout<<"輸入錯誤!斬!"<<endl;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
方宥鈞
時間:
2016-3-19 11:32
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
f:
int x;
cout<<"請輸入你的成績: ";
cin>>x;
if(x>=60 && x<=99)
cout<<"恭喜,通過考試了!!!!!!!!!!!!"<<endl;
else if(x==100)
cout<<"市長獎!棒棒!!!!!!"<<endl;
else if(x==0)
cout<<"聯絡簿拿來!!!!!!"<<endl;
else if(x>=1 && x<=59)
cout<<"不及格!!!!!!"<<endl;
else
cout<<"輸入錯誤!!!請稍後再試"<<endl;
goto f;
system("pause");
return 0;
}
複製代碼
作者:
高允懋
時間:
2016-3-19 11:34
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
a:
int x;
cout<<"請輸入你的成績:";
cin>>x;
if(x==100)
cout<<"哇!滿分!"<<endl;
else if(x<100 && x>=60)
cout<<"恭喜你及格了!給你糖吃!"<<endl;
else if(x<60 && x>0)
cout<<"不及格!打屁股!"<<endl;
else if(x==0)
cout<<"零分!斬!"<<endl;
else
cout<<"輸入錯誤!斬!"<<endl;
goto a;
system ("pause");
return 0;
複製代碼
作者:
康湍榆
時間:
2016-3-19 11:37
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
int score;
cout <<"請輸入你的成績:";
cin>>score;
if(score==100)
cout <<"滿分!恭喜(≧▽≦) "<<endl;
else if(score<100&&score>=60)
cout<<"及格!(≧▽≦)" <<endl;
else if(score<60&&score>0)
cout<<"不及格╯︿╰ " <<endl;
else if(score==0)
cout<<"零分⊙_⊙" <<endl;
else
cout<<"輸入錯誤(*-.-)"<<endl;
goto re;
system("pause");
return 0;
}
複製代碼
回復
1#
tonyh
作者:
陳泓瑜
時間:
2016-3-19 11:40
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int scr;
RE:
cout<<"PLEASE ENTER THE TEST SCORE: ";
cin>>scr;
if(scr==100)
cout<<"WOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOHHHHHHHHHAAAAAAOOOOOOOOOOOOOOOOOOOO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<endl;
else if(scr>=75 && scr<=100)
cout<<"HOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOORRRRRRRRRAAAAAAYYYYYYYYYYYYYYYYYY!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<endl;
else if(scr<=75 && scr>=48)
cout<<"NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOWHYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY????????????????????????????????????????????????"<<endl;
else if(scr<=48 && scr>=0)
cout<<"ORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZORZ"<<endl;
else if(scr==0)
cout<<"WHAT THE FXXK? WHAT ARE YOU DOING????? "<<endl;
else
cout<<"DAFUQ????? ARE YOU SERIOUS?????"<<endl;
goto RE;
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2