標題:
if...else if...else 敘述 - 成績分級程式
[打印本頁]
作者:
tonyh
時間:
2011-11-9 14:00
標題:
if...else if...else 敘述 - 成績分級程式
利用 if...else if...else 敘述, 試做一個成績分級程式:
90 ~ 100 優等
80 ~ 89 甲等
70 ~ 79 乙等
60 ~ 69 丙等
0 ~ 59 丁等
作者:
林宥辰
時間:
2011-11-9 14:15
回復
1#
tonyh
#include<iostream>
using namespace std;
int main()
{
int score;
cout<<"請輸入你的分數";
cin>>score;
if(score>=90&&score<=100)
{
cout<<"優!";
}else if(score>=80&& score<=89)
{
cout<<"甲";
}else if(score>=70&& score<=79)
{
cout<<"乙!";
}else if(score>=60&& score<=69)
{
cout<<"丙";
}else if(score>=0&& score<=59)
{
cout<<"丁";
cout<<"輸入錯誤!";
}
cout<<endl;
system("pause");
return 0;
}
作者:
陳詩凱
時間:
2011-11-9 14:16
#include<iostream>
using namespace std;
int main()
{
int score;
cout<<"請輸入你的分數: ";
cin>>score;
if(score==100)
{
cout<<"你可以考雄中!";
}else if(score>=90 and score<=100)
{
cout<<"好優喔!及格了!";
}else if(score>=80 and score<=89)
{
cout<<"你不錯喔!";
}else if(score>=70 and score<=79)
{
cout<<"你考乙?!我非宰了你不可!";
}else if(score>=60 and score<=69)
{
cout<<"你得丙?會被我打!";
}else if(score>=0 and score<=59)
{
cout<<"你居然得丁?";
}else
{
cout<<"輸入錯誤!";
}
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
洪咨伃
時間:
2011-11-9 14:16
回復
3#
陳詩凱
#include<iostream>
using namespace std;
int main()
{
int score;
cout<<"請輸入你的分數";
cin>>score;
if(score>=90&&score<=100)
{
cout<<"優!";
}else if(score>=80&& score<=89)
{
cout<<"甲";
}else if(score>=70&& score<=79)
{
cout<<"乙!";
}else if(score>=60&& score<=69)
{
cout<<"丙";
}else if(score>=0&& score<=59)
{
cout<<"丁";
cout<<"輸入錯誤!";
}
cout<<endl;
system("pause");
return 0;
}
作者:
黃崇維
時間:
2011-11-9 14:19
#include<iostream>
using namespace std;
int main()
{
int score;
cout<<"請輸入你(妳)的分數";
cin>>score;
if(score>=90&&score<=100)
{
cout<<"優";
}
else if(score>=80&&score<=89)
{
cout<<"甲";
}
else if(score>=70&&score<=79)
{
cout<<"乙";
}
else if(score>=60&&score<=69)
{
cout<<"丙";
}
else
{
cout<<"丁";
}
cout<<endl;
system("pause");
return 0;
}
作者:
黃崇維
時間:
2011-11-9 14:20
#include<iostream>
using namespace std;
int main()
{
int score;
cout<<"請輸入你(妳)的分數";
cin>>score;
if(score>=90&&score<=100)
{
cout<<"優";
}
else if(score>=80&&score<=89)
{
cout<<"甲";
}
else if(score>=70&&score<=79)
{
cout<<"乙";
}
else if(score>=60&&score<=69)
{
cout<<"丙";
}
else
{
cout<<"丁";
}
cout<<endl;
system("pause");
return 0;
}
作者:
黃崇維
時間:
2011-11-9 14:21
#include<iostream>
using namespace std;
int main()
{
int score;
cout<<"請輸入你(妳)的分數";
cin>>score;
if(score>=90&&score<=100)
{
cout<<"優";
}
else if(score>=80&&score<=89)
{
cout<<"甲";
}
else if(score>=70&&score<=79)
{
cout<<"乙";
}
else if(score>=60&&score<=69)
{
cout<<"丙";
}
else
{
cout<<"丁";
}
cout<<endl;
system("pause");
return 0;
}
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2