標題:
switch 判斷式
[打印本頁]
作者:
tonyh
時間:
2013-10-19 16:48
標題:
switch 判斷式
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score,level;
cout<<"請輸入你的成績: ";
cin>>score;
level=score/10;
switch(level)
{
case 10:
case 9:
case 8:
cout<<"甲等!";
break;
case 7:
cout<<"乙等!";
break;
case 6:
cout<<"丙等!";
break;
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:
cout<<"不及格!";
break;
default:
cout<<"輸入錯誤!";
}
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
張峻瑋
時間:
2013-10-19 16:57
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score,level;
cout<<"請輸入你的成績:"<<endl;
cin>>score;
level=score/10;
switch(level)
{
case 10:
case 9:
case 8:
cout<<"甲等!";
break;
case 7:
cout<<"乙等!";
break;
case 6:
cout<<"丙等!";
break;
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:
cout<<"不及格!";
break;
default:
cout<<"輸入錯誤!";
}
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
周雍程
時間:
2013-10-19 17:00
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int score,level;
cout << "請輸入你的成績:";
cin >> score;
level = score/10;
switch(level)
{
case 10:
case 9:
case 8:
cout <<"甲等!";
break;
case 7:
cout <<"乙等!";
break;
case 6:
cout <<"丙等!";
break;
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:
cout <<"丁等!";
break;
default:
cout <<"輸入錯誤!!!";
cout << endl;
}
system("pause");
return 0;
}
複製代碼
作者:
劉得旗
時間:
2013-10-19 17:00
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score,level;
cout<<"輸入你的成績: ";
cin>>score;
level=score/10;
switch(level)
{
case 10:
case 9:
case 8:
cout<<"甲等";
break;
case 7:
cout<<"已等";
break;
case 6:
cout<<"丙等";
break;
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:
cout<<"不及格";
break;
default:
cout<<"Error";
}
system("pause");
return 0;
}
複製代碼
作者:
張彥承
時間:
2013-10-19 17:04
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score,level;
cout<<"請輸入成績:"<<endl;
cin>>score;
level=score/10;
switch(level)
{
case 10:
case 9:
case 8:
cout<<"a+";
break;
case 7:
cout<<"b+";
break;
case 6:
cout<<"c+";
break;
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:
cout<<"fail";
break;
default:
cout<<"mistake";
}
system("pause");
return 0;
}
複製代碼
作者:
施伯叡
時間:
2013-10-19 17:07
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int score,level;
cout << "請輸入你的成績: ";
cin >> score;
level= score/10;
switch(level)
{
case 10:
case 9:
case 8:
cout<<"甲等";
break;
case 7:
cout<<"乙等";
break;
case 6:
cout<<"丙等";
break;
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:
cout<<"不及格";
break;
default:
cout<<"輸入錯誤";
}
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
張郁偵
時間:
2013-10-19 17:08
#include <iostream>
#include <cstdlib>
using namespace std;
int main ()
{
int score , level;
cout<<"請輸入你的成績:";
cin >> score;
level = score/10;
switch(level)
{
case 10:
case 9:
case 8:
cout<<"甲等";
break;
case 7:
cout<<"乙等";
break;
case 6:
cout<<"丙等";
break;
case 5:
case 4:
case 3:
case 2:
case 1:
cout<<"不及格";
break;
default:
cout<<"輸入錯誤";
}
system ("pause");
return 0;
}
複製代碼
作者:
張郁庭
時間:
2013-10-19 17:10
本帖最後由 張郁庭 於 2013-10-19 17:25 編輯
#include <iostream>
#include <cstdlib>
using namespace std;
int main ()
{
int score,level;
cout << "請輸入您的成績:";
cin >> score;
level = score/10;
switch (level)
{
case 10:
case 9:
case 8:
cout << " 甲等! ";
break;
case 7:
cout << " 乙等!" ;
break;
case 6:
cout << " 丙等! ";
break;
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:
cout << " 不及格! ";
break;
default:
cout << " 輸入錯誤! ";
}
cout << endl;
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2