codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
//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; }
Private
[
?
]
Run code
Submit