这就是我们千呼万唤始出来的机考练习题,坑爹的吧?如果说第一道的简单哈希虽然简单,毕竟与课程相关啊;但这个就不敢恭维了,典型就是给大一新生做的嘛。
Run Time: 0sec
Run Memory: 312KB
Code length: 572Bytes
Submit Time: 2011-12-27 21:54:55
// Problem#: 4700
// Submission#: 1138972
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <iostream>
using namespace std;
int main()
{
int T;
int N, n, m;
cin >> T;
while ( T-- ) {
cin >> N;
int max[ 4 ] = { };
while ( N-- ) {
cin >> m >> n;
if ( max[ m ] < n )
max[ m ] = n;
}
if ( max[ 1 ] != 0 )
cout << "1 " << max[ 1 ] << endl;
if ( max[ 2 ] != 0 )
cout << "2 " << max[ 2 ] << endl;
if ( max[ 3 ] != 0 )
cout << "3 " << max[ 3 ] << endl;
}
return 0;
}
本文分享了一道机考试题的解答思路及代码实现,题目要求处理输入数据并输出最大值,采用C++语言编写,适合计算机专业入门级学生参考。
648

被折叠的 条评论
为什么被折叠?



