二分查詢
題目描述:
輸入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
#include
#include
#include
using
namespace
std;
struct student
}buf[1000];
int main()
sort(buf,buf+n);
int t;
cin>>t;
while(t--!=0)else
if(tmp<0)else
top=mid-1;
} if(ans==-1)
查詢學生資訊
題目描述 輸入n個學生的資訊,然後進行查詢。輸入 輸入的第一行為n,即學生的個數 n 1000 接下來的n行包括n個學生的資訊,資訊格式如下 01 李江 男 21 02 劉唐 男 23 03 張軍 男 19 04 王娜 女 19 然後輸入乙個m m 10000 接下來會有m行,代表m次查詢,每行輸入...
查詢學生資訊
include include include include include include include include include includeusing namespace std typedef long long ll const int n 1e5 10,mod 1e6 con...
查詢學生資訊
輸入n個學生的資訊,然後進行查詢。輸入的第一行為n,即學生的個數 n 1000 接下來的n行包括n個學生的資訊,資訊格式如下 01 李江 男 21 02 劉唐 男 23 03 張軍 男 19 04 王娜 女 19 然後輸入乙個m m 10000 接下來會有m行,代表m次查詢,每行輸入乙個學號,格式如...