清華大學2023年機試 查詢學生資訊 1069

2021-08-07 09:53:47 字數 1220 閱讀 3763

題目描述:

輸入n個學生的資訊,然後進行查詢。

輸入

輸入的第一行為n,即學生的個數(n<=1000)

接下來的n行包括n個學生的資訊,資訊格式如下:

01 李江 男 21

02 劉唐 男 23

03 張軍 男 19

04 王娜 女 19

然後輸入乙個m(m<=10000),接下來會有m行,代表m次查詢,每行輸入乙個學號,格式如下:

02 03

01 04

輸出

輸出m行,每行包括乙個對應於查詢的學生的資訊。

如果沒有對應的學生資訊,則輸出「no answer!」

樣例輸入

4 01 李江 男 21

02 劉唐 男 23

03 張軍 男 19

04 王娜 女 19

5 02

03 01

04 03

樣例輸出

02 劉唐 男 23

03 張軍 男 19

01 李江 男 21

04 王娜 女 19

03 張軍 男 19

解題思路:

簡單模擬。

注意中文的儲存:中文佔兩個位元組,而char只佔1個位元組,為避免該問題,用string處理比較合適。

ac**:

#include 

#include

#include

#include

using

namespace

std;

const

int maxn = 1010;

const

int maxm = 10010;

int n, m;

struct recordrecords[maxn];

map idmap;

void printrecord(int i)

scanf("%d", &m);

for(int i = 0; i < m; i++)

}fclose(stdin);

return

0;}

清華大學2023年機試 球的半徑和體積 1068

題目描述 輸入球的中心點和球上某一點的座標,計算球的半徑和體積 輸入 球的中心點和球上某一點的座標,以如下形式輸入 x0 y0 z0 x1 y1 z1 輸出 輸入可能有多組,對於每組輸入,輸出球的半徑和體積,並且結果保留三位小數 樣例輸入 0 0 0 1 1 1 樣例輸出 1.732 21.766 ...

查詢學生資訊 清華大學

牛客網題目鏈結 排序題。先儲存再查詢 include include include include include include include include include include using namespace std const int n 1005 typedef pair i...

清華大學2023年機試 遞推數列 1081

題目描述 給定a0,a1,以及an p a n 1 q a n 2 中的p,q。這裡n 2。求第k個數對10000的模。輸入 輸入包括5個整數 a0 a1 p q k。輸出 第k個數a k 對10000的模。樣例輸入 20 1 1 14 5 樣例輸出 8359 解題思路 首先,第一反應是用遞迴解題,...