標題:
if...else if...else 判斷式
[打印本頁]
作者:
王瑞喻
時間:
2020-3-27 14:06
標題:
if...else if...else 判斷式
關係運算
== 等於
< 小於
> 大於
<= 小於或等於
>= 大於或等於
!= 不等於
邏輯運算
&& and
|| or
#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;
}
複製代碼
作者:
鐘彥博
時間:
2020-3-28 17:18
#include<cstdlib>
using namespace std;
int main()
{
int score;
re:
cout<<"請輸入你的分數:";
cin>>score;
if(score>59 && score<100)
{
cout<<"恭喜你及格了,給你糖吃!" <<endl;
}else if(score>=0 && score<60)
{
cout<<"不及格!打屁股!" <<endl;
}else if(score=0)
{
cout<<"零分?斬!" <<endl;
}else if(score=100)
{
cout<<"哇!滿分!" <<endl;
}else
{
cout<<"輸入錯誤!斬!" <<endl;
}
goto re;
system("pause");
return 0;
}
複製代碼
作者:
董定宇
時間:
2020-3-28 17:18
#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<<"哇!0分!"<<endl;
else
cout<<"哇!斬!"<<endl;
goto re;
system("pause");
return 0;
}
複製代碼
回復
1#
王瑞喻
作者:
呂尚霖
時間:
2020-3-28 17:20
#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;
}
複製代碼
作者:
林帛毅
時間:
2020-3-28 17:23
#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;
}
複製代碼
作者:
夏子涵
時間:
2020-4-11 15:17
#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;
}
複製代碼
作者:
謝承志
時間:
2020-4-16 18:45
#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;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2