每個(gè)PAT考生在參加考試時(shí)都會(huì)被分配兩個(gè)座位號(hào),一個(gè)是試機(jī)座位,一個(gè)是考試座位。正常情況下,考生在入場(chǎng)時(shí)先得到試機(jī)座位號(hào)碼,入座進(jìn)入試機(jī)狀態(tài)后,系統(tǒng)會(huì)顯示該考生的考試座位號(hào)碼,考試時(shí)考生需要換到考試座位就座。但有些考生遲到了,試機(jī)已經(jīng)結(jié)束,他們只能拿著領(lǐng)到的試機(jī)座位號(hào)碼求助于你,從后臺(tái)查出他們的考試座位號(hào)碼。
輸入格式:
輸入第一行給出一個(gè)正整數(shù)N(<=1000),隨后N行,每行給出一個(gè)考生的信息:“準(zhǔn)考證號(hào) 試機(jī)座位號(hào) 考試座位號(hào)”。其中準(zhǔn)考證號(hào)由14位數(shù)字組成,座位從1到N編號(hào)。輸入保證每個(gè)人的準(zhǔn)考證號(hào)都不同,并且任何時(shí)候都不會(huì)把兩個(gè)人分配到同一個(gè)座位上。 考生信息之后,給出一個(gè)正整數(shù)M(<=N),隨后一行中給出M個(gè)待查詢(xún)的試機(jī)座位號(hào)碼,以空格分隔。
輸出格式: 對(duì)應(yīng)每個(gè)需要查詢(xún)的試機(jī)座位號(hào)碼,在一行中輸出對(duì)應(yīng)考生的準(zhǔn)考證號(hào)和考試座位號(hào)碼,中間用1個(gè)空格分隔。
輸入樣例: 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. 換了輸入法的皮膚。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注