標題:
if...else if...else 判斷式
[打印本頁]
作者:
tonyh
時間:
2016-5-23 09:41
標題:
if...else if...else 判斷式
本帖最後由 tonyh 於 2016-5-23 10:34 編輯
#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;
cout<<endl;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
邱柏揚
時間:
2016-5-23 10:10
本帖最後由 邱柏揚 於 2016-5-23 10:33 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
re:
cout<<"請輸入你的成績:";
cin>>score;
if(score==100)
cout<<"滿分!"<<endl;
else if(score>=60 && score<=99)
cout<<"及格!"<<endl;
else if(score>0 && score<60)
cout<<"不及格!!"<<endl;
else if(score==0)
cout<<"零分!"<<endl;
else
cout<<"錯誤!"<<endl;
cout<<endl;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
王淳暘
時間:
2016-5-23 10:10
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
cout<<"請輸入你的成績:";
cin>>score;
if(score==100)
cout<<"哇!滿分!!"<<endl;
else if(score>=60 and score<100)
cout<<"恭喜你,及格了!"<<endl;
else if(score>0 and score<60)
cout<<"不及格,斬!"<<endl;
else if(score==0)
cout<<"零分,斬!"<<endl;
else if(score<0 and score<60)
cout<<"不及格,斬!"<<endl;
else
cout<<"亂輸入,斬!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
張恩嘉
時間:
2016-5-23 10:14
本帖最後由 張恩嘉 於 2016-5-23 10:34 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
re:
cout<<"請輸入你的成績: ";
cin>>score;
if(score==100)
cout<<"你得到滿分!"<<endl;
else if(score>=60 && score<=99)
cout<<"你得到及格"<<endl;
else if(score>0 && score<60)
cout<<"你得到不及格"<<endl;
else if(score==0)
cout<<"你得到零分"<<endl;
else
cout<<"亂輸入,笨 "<<endl;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
邱士杰
時間:
2016-5-23 10:14
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
cout<<"請輸入你的成績:";
cin>>score;
if(score==100)
cout<<"哇!滿分!"<<endl;
else if(score>=60 and score<=99)
cout<<"及格了!"<<endl;
else if(score>=1 and score<60)
cout<<"不及格!斬!"<<endl;
else if (score=0)
cout<<"零分!斬!"<<endl;
else
cout<<"亂輸入!斬!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
謝易錚
時間:
2016-5-23 10:14
本帖最後由 謝易錚 於 2016-5-23 10:34 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
re:
cout<<"輸入成績:";
cin>>score;
if(score==100)
cout<<"啊不就好厲害"<<endl;
else if(score>=60 && score<=99)
cout<<"030"<<endl;
else if(score>0 && score<60)
cout<<"你還有時間玩電腦!!"<<endl;
else if(score==0)
cout<<"心已死(嘆氣"<<endl;
else
cout<<"輸入錯囉!"<<endl;
cout<<endl;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
林禹彤
時間:
2016-5-23 10:15
本帖最後由 林禹彤 於 2016-5-23 10:34 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
re:
cout<<"今天考幾分?";
cin>>score;
if(score==100)
cout<<"跩喔?!"<<endl;
else if(score>=80 && score<100)
cout<<"啊不就好棒棒?!!"<<endl;
else if(score>=60 && score<80)
cout<<"勉強及格....."<<endl ;
else if(score>=0 && score<60)
cout<<"晚上有竹筍炒肉絲可以吃了!!"<<endl;
else
cout<<"哩麥來亂!!!閃邊去"<<endl;
cout<<endl;
goto re;
system ("pause");
return 0;
}
複製代碼
作者:
孫漢瑄
時間:
2016-5-23 10:17
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int score;
cout<<"請輸入你的成績";
cin>>score;
if (score==100)
{
cout<<"恭喜你"<<endl;
}else if(score>=60 && score<=99)
{
cout<<"哇!好棒棒"<<endl;
}else if(score<60 && score>0)
{
cout<<"不及格欸"<<endl;
}else if(score==0)
{
cout<<"糟糕"<<endl;
}else
{
cout<<"亂輸入"<<endl;
}
system ("pause");
return 0;
}
複製代碼
作者:
洪為濬
時間:
2016-5-23 10:19
本帖最後由 洪為濬 於 2016-5-23 10:33 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
re:
cout<<"請輸入你的成績";
cin>>score;
if(score==100)
cout<<"棒棒~~"<<endl;
else if(score>=60&&score<100)
cout<<"有及格就好"<<endl;
else if(score>0&&score<=60)
cout<<"不及格沒關係"<<endl;
else if(score==0)
cout<<"考得真好"<<endl;
else
cout<<"輸入錯誤,累積三次會爆炸" <<endl;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
劉瑑恩
時間:
2016-5-23 10:19
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
cout<<"請輸入你的成績:";
cin>>score;
if(score==100)
cout<<"你好棒棒喔!"<<endl;
else if(score>=60&&score<=99)
cout<<"及格了!"<<endl;
else if(score>0&&score<60)
cout<<"打屁股!"<<endl;
else if(score==0)
cout<<"零分?!狗頭鍘伺候"<<endl;
else
cout<<"亂輸入!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
蔡孟君
時間:
2016-5-23 10:19
本帖最後由 蔡孟君 於 2016-5-23 10:34 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
re:
cout<<"請輸入你的成績";
cin>>score;
if(score==100)
{
cout<<"Great!!100%~~"<<endl;
}else if(score>=60&&score<=99)
{
cout<<"so close!!"<<endl;
}else if(score>0&&score<60)
{
cout<<"Oh oh~didn't pass...."<<endl;
}else if(score=0)
{
cout<<"you got ZERO!?!?!?!?"<<endl;
}else
{
cout<<"IDIOT!"<<endl;
}
goto re;
system("pause");
return 0;
}
複製代碼
作者:
劉得榮
時間:
2016-5-23 10:21
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
cout<<"請輸入你的成績:";
cin>>score;
if(score==100)
cout<<"哇!滿分!"<<endl;
else if(score>=60&&score<=99)
cout<<"及格了!"<<endl;
else if(score>0&&score<60)
cout<<"不及格"<<endl;
else if(score==0)
cout<<"零分!斬!"<<endl;
else
cout<<"白目!斬!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
蔡孟庭
時間:
2016-5-23 10:22
#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-5-23 10:25
#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-5-23 10:34
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
re:
cout<<"請輸入你的成績:";
cin>>score;
if(score==100)
cout<<"滿分耶讚喔"<<endl;
else if(score>=60&&score<=99)
cout<<"你及格了"<<endl;
else if(score>0&&score<60)
cout<<"不及格"<<endl;
else if(score==0)
cout<<"居然零分你完了"<<endl;
else
cout<<"輸入錯誤"<<endl;
cout<<endl;
goto re;
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2