[ create a new paste ] login | about

Link: http://codepad.org/HLrLqHqr    [ raw code | output | fork ]

박정욱 - C++, pasted on Apr 20:
//객체지향 금123 2012.04.20
//3번		200911636박정욱
#include<iostream>
#include<iomanip>
using namespace std;

// 
void population(int table[][6])
{
	int i,j;

	cout << "age\code	";
	for(j=0 ; j <6 ; j++)
	{	cout << "  j	";	}
	cout << endl;

	for(i=0 ; i <5 ; i++)
	{	if(i != 4){cout << i*20 << "이상~"<< (i+1)*20<<"미만	";}
		else{cout << (i)*20 << "이상~		";}
		for(j=0 ; j <6 ; j++)
		{	cout <<"  "<< table[i][j]<<"	";	}
		cout << endl;
	}
};

void check(int age, int code, int table[][6])
{
	switch(age/20)
	{
		case 0 :	{table[0][code]++;}break;
		case 1 :	{table[1][code]++;}break;
		case 2 :	{table[2][code]++;}break;
		case 3 :	{table[3][code]++;}break;
		default : {table[4][code]++;}
				  break;
	}
};

int main()
{
	int table[5][6]={0}; //table[나이][지역코드] ; 0:0~20/1:20~40/3:40~60/4:60~80/5:80이상
	int i,age, code;
	cout << "나이/ 지역코드를 입력하세요.(코드: 1~6)" << endl;
	
	for(i=0 ; i<10 ;i++)
	{	cin >> age >> code;	
		if(age >=0 && code >=1 && code <=6)
		{	check(age, code-1, table);	}
		else
		{	cout << "error:나이와 지역코드를 확인하시오.\n";	i--;}
	}

	population(table);

	return 0;
}


Output:
1
2
Line 24: error: extra ';'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: