標題:
if...else if...else 判斷式
[打印本頁]
作者:
王瑞喻
時間:
2020-7-24 16:00
標題:
if...else if...else 判斷式
關係運算
== 等於
< 小於
> 大於
<= 小於或等於
>= 大於或等於
!= 不等於
邏輯運算
&& and
|| or
#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-7-24 16:31
#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-7-24 16:33
#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-7-24 16:34
#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==0)
cout<<"不及格!打屁股!"<<endl;
else if(score<60 && score>0)
cout<<"不及格!打屁股!"<<endl;
else
cout<<"輸入錯誤!斬!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
黃韋誌
時間:
2020-7-24 16:34
#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-7-24 16:34
#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-7-24 16:35
#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-7-24 16:36
#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-7-24 16:36
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
cout<<"請輸入你的成績: ";
cin>>score;
if(score==60)
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-7-24 16:36
#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;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2