標題:
015_簡單成績評等
[打印本頁]
作者:
游東祥
時間:
2015-5-9 11:36
標題:
015_簡單成績評等
宣告一個整數變數讓使用者輸入一個分數(0~100)
如果分數是 90~100 得 A
如果分數是 80~89 得 B
如果分數是 70~79 得 C
如果分數是 60~69 得 D
否則就"不及格"
作者:
王翔
時間:
2015-5-9 11:59
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
while(true)
{
int score = 0;
int level = 0;
cout << "輸入分數:";
cin >> score;
level = score/10;
switch(level) {
case 10:
case 9:
cout << "得A" << endl;
break;
case 8:
cout<< "得B" << endl;
break;
case 7:
cout<<"得C" << endl;
break;
case 6:
cout<< "得D" << endl;
break;
default:
cout<<"不及格"<<endl;
}
system ("pause");
}
return 0;
}
複製代碼
作者:
吳承勳
時間:
2015-5-9 12:03
#include<iostream>
#include<cstdlib>
using namespace std;
main()
{
while(true)
{
int score;
cout << "請輸入分數(0~100):" << endl;
cin >> score;
int level = score / 10;
switch(level)
{
case 10:
case 9:
cout << "A" << endl;
break;
case 8:
cout << "B" << endl;
break;
case 7:
cout << "C" << endl;
break;
case 6:
cout << "D" << endl;
break;
default:
cout << "不及格" << endl;
break;
}
system("pause");
}
return 0;
}
複製代碼
作者:
林廷翰
時間:
2015-5-9 12:04
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
while(true)
{
int score;
cout<<"請輸入一個分數(0~100):";
cin>>score;
int level = (int)(score/10);
switch(level)
{
case 10:
case 9:
cout<<"a"<<endl;
break;
case 8:
cout<<"b"<<endl;
break;
case 7:
cout<<"c"<<endl;
break;
case 6:
cout<<"d"<<endl;
break;
default:
cout<<"不及格"<<endl;
}
return 0;
}
}
複製代碼
作者:
黃璽安
時間:
2015-5-9 12:04
#include<iostream>
#include<cstdlib>
using namespace std;
main ()
{
while (true)
{
int score;
cout<<"請輸入一個分數(0~100):";
cin>>score;
int level= (int)(score/10);
switch(level)
{
case 10:
case 9:
cout<<"A"<<endl;
break;
case 8:
cout<<"B"<<endl;
break;
case 7:
cout<<"C"<<endl;
break;
case 6:
cout<<"D"<<endl;
break;
default:
cout<<"不及格"<<endl;
}
system ("pause");
}
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2