U E D R , A S I H C RSS

데블스캠프2006/월요일/연습문제/switch/이차형

== 이차형 ==

~cpp
#include <iostream>
using namespace std;

int main()
{	
	int i;
	int n;
	int A, B, C, D, F;
	A = B = C = D = F = 0;
	int count = 0;

	do
	{
		cout << "성적을 입력하시기 바랍니다.\n";
		cout << "[ 성적은 100이하 ] [ 종료조건 999입력 ] : ";
		cin >> n;
		cout << "\n";
		i++;
		
		switch(n / 10)
		{
		case 10:
		case 9:
			A++;
			break;
		case 8:
			B++;
			break;
		case 7:
			C++;
			break;
		case 6:
			D++;
			break;
		case 5:
		case 4:
		case 3:
		case 2:
		case 1:
		case 0:
			F++;
			break;
		default :
			break;
		}
	}while(n != 999 && count < 10);

	cout << "A는" << A << "명 입니다.\n";
	cout << "B는" << B << "명 입니다.\n";
	cout << "C는" << C << "명 입니다.\n";
	cout << "D는" << D << "명 입니다.\n";
	cout << "F는" << F << "명 입니다.\n";
	

	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:05
Processing time 0.0239 sec