[ create a new paste ] login | about

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

hoaithu.melody - C++, pasted on Mar 9:
//FindMode
#include <iostream>
#include <conio.h>

using namespace std;
int main()
{
	int n;
	int point[1000];
	int count[201];
	freopen("Testcase.txt", "r", stdin);
	for(int i = 1; i <= 10; i++)
	{
		int max = 0, mode;
		int j;
		cin >> n;
		for(j = 0; j < 1000; j++)
			cin >> point[j];

		for(j = 0; j < 201; j++)
			count[j] = 0;

		for(j = 0; j < 1000; j++)
			count[point[j]] ++;

		for(j = 0; j < 201; j++)
			if(max <= count[j])
			{
				max = count[j];
				mode = j;
			}

		cout << "#" << i << " " << mode << endl;
	}
	getch();
	return 0;
}


Output:
1
2
3
4
Line 18: error: conio.h: No such file or directory
In function 'int main()':
Line 35: error: 'getch' was not declared in this scope
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: