標題:
if...else if...else 判斷式
[打印本頁]
作者:
王瑞喻
時間:
2020-7-25 18:24
標題:
if...else if...else 判斷式
關係運算
== 等於
< 小於
> 大於
<= 小於或等於
>= 大於或等於
!= 不等於
邏輯運算
&& and
|| or
作者:
柏霖
時間:
2020-7-25 20:25
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
cout<<"請輸入你的成績: ";
cin>>score;
if(score==100)
{
cout<<"哇! 滿分!"<<endl;
}
else if(score<=99 && score>=60)
{
cout<<"恭喜你及格了!給你糖吃!"<< endl;
}
else if(score>0 && score<60)
{
cout<<"不及格!打屁股!"<<endl;
}
else if(score==0)
{
cout<<"零分?斬!"<<endl;
}
else
{
cout<<"輸入錯誤!斬!"<<endl;
}
system ("pause");
return 0;
}
複製代碼
作者:
蔡旭恩
時間:
2020-7-25 20:26
#include<iostream>
#include<cstdlib>
using namespace std;
int main ()
{
float answer;
cout<<"輸入你的成績: ";
cin>>answer;
if(answer>=60 && answer<101)
{
cout<<"及格"<<endl;
}
else if(answer<59 && answer>0)
{
cout<<"沒有認真嗎?"<<endl;
}
else if(answer==0)
{
cout<<"沒關係,我也考0分"<<endl;
}
else if(answer==520)
{
cout<<"我也愛你. :DD"<<endl;
}
else
{
cout<<"0-100而已"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
顏宇鋒
時間:
2020-7-25 20:27
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x; //分數
cout<<"請輸入你的成績: ";
cin>>x;
if(x==100)
{
cout<<"哇!滿分!"<<endl;
}
else if(x>=60&&x<=99)
{
cout<<"恭喜你及格了!給你糖吃!"<<endl;
}
else if(x<60&&x>=1)
{
cout<<"不及格!打屁股!"<<endl;
}
else if(x==0)
{
cout<<"零分??斬!"<<endl;
}
else
{
cout<<"輸入錯誤!誅九你族!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
呂宸瑄
時間:
2020-7-25 20:28
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
cout<<"請輸入你的成績:";
cin>>score;
if(score==100)
{
cout<<"哇!滿分!"<<endl;
}
else if(score<=99 &&score>=60)
{
cout<<"恭喜你及格,給你糖吃!"<<endl;
}
else if(score<=59 &&score>=1)
{
cout<<"不及格! 打屁股!"<<endl;
}
else if(score==0)
{
cout<<"零分! 斬!"<<endl;
}
else
{
cout<<"輸入錯誤! 斬!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
文硯
時間:
2020-7-25 20:28
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
cout<<"請輸入你的成績: ";
cin>>score;
if(score==100)
{
cout<<"哇!滿分!"<<endl;
}
else if(score<=99 && score>=60)
{
cout<<"恭喜你及格了,給你糖吃!"<<endl;
}
else if(score<60 && score>=1)
{
cout<<"不及格!打屁股!"<<endl;
}
else if(score==0)
{
cout<<"零分!斬!"<<endl;
}
else
{
cout<<"輸入錯誤!斬!"<<endl;
}
system ("pause");
return 0;
}
複製代碼
作者:
曾元瑜
時間:
2020-7-25 20:29
#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-25 20:30
#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>=1)
{
cout<<"不及格,打屁股"<<endl;
}
else if(score==0)
{
cout<<"零分,斬!"<<endl;
}
else
cout<<"輸入錯誤,斬!"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
陳泳淇
時間:
2020-7-25 20:30
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
cout<<"Insert your score: ";
cin>>score;
if (score==100)
{
cout<<"Wow! Full marks!"<<endl;
}
else if (score<=100&&score>=60)//60-99
{
cout<<"Congrats on getting a full mark!"<<endl;
}
else if (score<60&&score>=1)//1-59
{
cout<<"Didn't pass!"<<endl;
}
else if (score==0)
{
cout<<"Zero?"<<endl;
}
else if (score<0&&score>100)//0-100
{
cout<<"Error."<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
蔡坤辰
時間:
2020-7-25 20:33
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
cout<<"請輸入你的成績: ";
cin>>score;
if(score==100)
{
cout<<"哇! 滿分!"<<endl;
}
else if(score<=99 && score>=60)
{
cout<<"恭喜你及格了!給你糖吃!"<< endl;
}
else if(score>0 && score<60)
{
cout<<"不及格!打屁股!"<<endl;
}
else if(score==0)
{
cout<<"零分?斬!"<<endl;
}
else
{
cout<<"輸入錯誤!斬!" <<endl;
}
system ("pause");
return 0;
}
複製代碼
作者:
張博翔
時間:
2020-7-25 20:34
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
cout<<"請輸入你的成績:";
cin>>score;
if(score==100)
{
cout<<"哇!滿分!"<<end1;
}
else if(score<100 && score>=60) //60-99
{
cout<<"恭喜你及格了,給你吃糖"<<end1;
}
else if(score<60 && score>=1) //1-59
{
cout<<"不及格!打屁股"<<end1;
}
else if(score==0)
{
cout<<"0分,斬"<<end1;
else
{
cout<<<<"輸入錯誤"<<end1;
}
system("pause");
return 0;
}
複製代碼
作者:
吳湘儀
時間:
2020-7-25 20:40
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x; //分數
cout<<"請輸入你的成績: ";
cin>>x;
if(x==100)
{
cout<<"哇!滿分!"<<endl;
}
else if(x>=60&&x<=99)
{
cout<<"恭喜你及格了!給你糖吃!"<<endl;
}
else if(x<60&&x>=1)
{
cout<<"不及格!打屁股!"<<endl;
}
else if(x==0)
{
cout<<"零分??斬!"<<endl;
}
else
{
cout<<"輸入錯誤!誅九你族!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
張博竣
時間:
2020-7-25 20:40
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
cout<<"請輸入你的成績: ";
cin>>score;
if(score==100)
{
cout<< "哇!滿分!"<<endl;
}
else if(score<=99 && score>=60)
{
cout<<"恭喜你及格了,給你糖吃!"<<endl;
}
else if(score<60 && score>=1)
{
cout<<"不及格! 打屁股!"<<endl;
}
else if(score==0)
{
cout<<"零分?斬!"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
趙品昀
時間:
2020-7-25 20:42
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score;
cout<<"請輸入你的成績:";
cin>>score;
if(score==100)
{
cout<<"喔?偷作弊齁?"<<endl;
}
else if (score<=99 && score>=60) //60-99
{
cout<<"嗯?!你希望我說什麼?"<<endl;
}
else if (score<60 && score>=1) //1-59
{
cout<<"白X加三級"<<endl;
}
else if (score==0)
{
cout<<"沒救!!!"<<endl;
}
else
{
cout<<"輸入錯誤!文盲?"<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
洪勻蓁
時間:
2021-3-8 21:00
#include<iostream>
#include<cstdlib>
using namespace std;
int main ()
{
int score;
cout<<"請輸入你的成績:";
cin>>score;
if(score==100)
{
cout<<"滿分!好棒:D"<<endl;
}
else if(score<=99 && 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