1004
#include <iostream>
#include <cstdio>
#include <string>
//#include <algorithm>
using namespace std;
int main()
{
int n;
cin >> n;
int flag = 1;
string a, b;
int xue,max,min;
string aa[101], bb[101];//可以直接用string记得头文件噢!!
while (n != 0)
{
cin >> a >> b >> xue;
aa[xue] = a;
bb[xue] = b;
if (flag) //为了比大小节省,主要是不懂大有多大,小有多小的时候用哦
{
max = xue;
min = xue;
flag = 0;
}
else
{
if (xue > max)
{
max = xue;
}
if (xue < min)
{
min = xue;
}
}
n--;
}
cout << aa[max] << " " << bb[max]<<endl;
cout << aa[min] << " " << bb[min];
system("pause");
return 0;
}
1041
输入格式:
输入第一行给出一个正整数 N(≤1000),随后 N 行,每行给出一个考生的信息:准考证号 试机座位号 考试座位号
。其中准考证号
由 14 位数字组成,座位从 1 到 N 编号。输入保证每个人的准考证号都不同,并且任何时候都不会把两个人分配到同一个座位上。
考生信息之后,给出一个正整数 M(≤N),随后一行中给出 M 个待查询的试机座位号码,以空格分隔。
输出格式:
对应每个需要查询的试机座位号码,在一行中输出对应考生的准考证号和考试座位号码,中间用 1 个空格分隔。
#include <iostream>
#include <cstdio>
#include <string>
//#include <algorithm>
using namespace std;
int main()
{
int N,M;
cin >> N;
string ss[10000];
int a[1000];
int b[10000]; //开大一点噢~
int n = 0;
string sss;
while (N != 0)
{
cin >> sss >> a[n];
cin>> b[a[n]]; //分开写要不然会报错= =
ss[a[n++]] = sss;
N--;
}
cin >> M;
int j = 0;
while (M != 0)
{
int k;
cin >> k;
cout << ss[k] << " " << b[k]<<endl;
M--;
j = 0;
}
system("pause");
return 0;
}