输入格式:
输入在第一行给出正整数N(≤10);随后N行,每行按照格式姓名 生日 性别 固话 手机给出一条记录。其中姓名是不超过10个字符、不包含空格的非空字符串;生日按y/m/d的格式给出年月日;性别用M表示“男”、F表示“女”;固话和手机均为不超过15位的连续数字,前面有可能出现+。
在通讯录记录输入完成后,最后一行给出正整数K,并且随后给出K个整数,表示要查询的记录编号(从0到N−1顺序编号)。数字间以空格分隔。
输出格式:
对每一条要查询的记录编号,在一行中按照姓名 固话 手机 性别 生日的格式输出该记录。若要查询的记录不存在,则输出Not Found。
输入样例:
3
Chris 1984/03/10 F +86181779452 13707010007
LaoLao 1967/11/30 F 057187951100 +8618618623333
QiaoLin 1980/01/01 M 84172333 10086
2 1 7
结尾无空行
输出样例:
LaoLao 057187951100 +8618618623333 F 1967/11/30
Not Found
结尾无空行
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
struct phonebook
{
string name, birthday, sex, stickphone, phone;
};
int main()
{
string Name, Birthday, Sex, cantmovedphone, movebyPhone;
phonebook num1[10];
int a;
cin >> a;
for (int i = 0; i < a; i++)
{
cin >> Name >> Birthday >> Sex >> cantmovedphone >> movebyPhone;
num1[i].name = Name;
num1[i].birthday = Birthday;
num1[i].sex = Sex;
num1[i].stickphone = cantmovedphone;
num1[i].phone = movebyPhone;
}
int number;
int put[1000];
int n;
cin >> number;
for (int i = 0; i < number; i++)
{
cin >> n;
put[i] = n;
}
for (int i = 0; i < number-1; i++)
{
if (put[i] < a)
cout << num1[put[i]].name << " " << num1[put[i]].stickphone << " " << num1[put[i]].phone << " " << num1[put[i]].sex << " " << num1[put[i]].birthday << endl;
else
cout << "Not Found" << endl;
}
number = number - 1;
if (put[number] < a)
cout << num1[put[number]].name << " " << num1[put[number]].stickphone << " " << num1[put[number]].phone << " " << num1[put[number]].sex << " " << num1[put[number]].birthday;
else
cout << "Not Found";
}