每個PAT考生在參加考試時都會被分配兩個座位號,一個是試機座位,一個是考試座位。正常情況下,考生在入場時先得到試機座位號碼,入座進入試機狀態后,系統會顯示該考生的考試座位號碼,考試時考生需要換到考試座位就座。但有些考生遲到了,試機已經結束,他們只能拿著領到的試機座位號碼求助于你,從后臺查出他們的考試座位號碼。
輸入格式:
輸入第一行給出一個正整數N(<=1000),隨后N行,每行給出一個考生的信息:“準考證號 試機座位號 考試座位號”。其中準考證號由14位數字組成,座位從1到N編號。輸入保證每個人的準考證號都不同,并且任何時候都不會把兩個人分配到同一個座位上。 考生信息之后,給出一個正整數M(<=N),隨后一行中給出M個待查詢的試機座位號碼,以空格分隔。
輸出格式: 對應每個需要查詢的試機座位號碼,在一行中輸出對應考生的準考證號和考試座位號碼,中間用1個空格分隔。
輸入樣例: 4 10120150912233 2 4 10120150912119 4 1 10120150912126 1 3 10120150912002 3 2 2 3 4
輸出樣例: 10120150912002 2 10120150912119 1
Answer:
#include<iostream>using namespace std;struct stu { long long sno; int mac; int test; inline stu() { this->sno = 0; this->mac = 0; this->test = 0; } inline void output() { cout << this->sno << ' ' << this->test << '/n'; }};int main() { int n; cin >> n; stu *result[n]; long long sno; int mac, test; for(int i = 0; i < n; i ++) { cin >> sno >> mac >> test; result[mac] = new stu(); result[mac]->sno = sno; result[mac]->mac = mac; result[mac]->test = test; } int m; cin >> m; int search[m]; for(int i = 0; i < m; i ++) { cin >> search[i]; } for(int i = 0; i < m; i ++) { result[search[i]]->output(); }}PS. 換了輸入法的皮膚。
新聞熱點
疑難解答