#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define inf 0x3f3f3f3f
#define minc(a,b) (((a)<(b)) ? (a) : (b))
#define maxc(a,b) (((a)>(b)) ? (a) : (b))
int read( ) {
int ret= 0 , ttt= 1 ;
while ( ch< '0' || ch> '9' ) {
if ( ch== '-' ) {
ttt=- 1 ;
} while ( ch>= '0' && ch<= '9' ) {
ret= ( ret<< 1 ) + ( ret<< 3 ) + ( ch^ 48 ) ;
} return ret* ttt;
}
struct info{
char name[ 35 ] , no[ 35 ] , bp[ 35 ] , age[ 5 ] , sex[ 35 ] ;
} ;
struct info stu[ 130 ] ;
//tran 负责把读入的整行字符串断成小部分赋值给目标对象。参数s为读入的整行字符串,tar为目标对象,i为计数器,l为整行长度。
void tran( char * s, char * tar, int * i, int l) {
int cnt= 0 ;
//printf("%s %d\n",s,l);
for ( ; ( * i) < l; ( * i) ++ ) {
//printf("%d %c",*i,s[*i]);
if ( s[ * i] == ',' ) break ;
tar[ cnt] = s[ * i] ;
cnt++;
}
//printf("\n");
tar[ cnt] = '\0 ' ;
return ;
}
void input( int x) {
char s[ 200 ] ;
tran( s, stu[ x] .name ,& ind, l) ;
ind+= 2 ;
tran( s, stu[ x] .no ,& ind, l) ;
ind+= 2 ;
tran( s, stu[ x] .bp ,& ind, l) ;
ind+= 2 ;
tran( s, stu[ x] .age ,& ind, l) ;
ind+= 2 ;
tran( s, stu[ x] .sex ,& ind, l) ;
return ;
}
void output( int x) {
printf ( "%s, %s, %s, %s, %s\n " , stu
[ x
] .
name , stu
[ x
] .
no , stu
[ x
] .
bp , stu
[ x
] .
age , stu
[ x
] .
sex ) ; return ;
}
//chk 检验a[y](定义与主函数中一致,查询请求的第y个信息)与stu[x]中某个信息完全一致,是则返回1.
int chk( int y, int x, char ( * a) [ 200 ] ) {
int f= 0 ;
if ( ! strcmp ( a
[ y
] , stu
[ x
] .
name ) ) f
= 1 ; if ( ! strcmp ( a
[ y
] , stu
[ x
] .
no ) ) f
= 1 ; if ( ! strcmp ( a
[ y
] , stu
[ x
] .
bp ) ) f
= 1 ; if ( ! strcmp ( a
[ y
] , stu
[ x
] .
age ) ) f
= 1 ; if ( ! strcmp ( a
[ y
] , stu
[ x
] .
sex ) ) f
= 1 ; return f;
}
int main( ) {
//freopen("Structure.in","r",stdin);
//freopen("Structure.out","w",stdout);
int n= read( ) ;
for ( int i= 1 ; i<= n; i++ ) {
input( i) ;
output( i) ;
}
char s[ 200 ] , a[ 6 ] [ 200 ] ;
int l;
while ( 1 ) {
if ( l>= 4 ) {
if ( s[ 0 ] == 'q' && s[ 1 ] == 'u' && s[ 2 ] == 'i' && s[ 3 ] == 't' ) break ;
}
int ind= 0 , cnt= 0 ;
while ( ind< l) {
cnt++;
tran( s, a[ cnt] ,& ind, l) ;
//printf("%s ",a[cnt]);
ind++;
}
//printf("\n");
int ans[ 130 ] , num= 0 ;
for ( int i= 1 ; i<= n; i++ ) {
int f= 1 ;
for ( int j= 1 ; j<= cnt; j++ ) {
f= f && chk( j, i, a) ;
}
if ( f) {
//f==1 代表请求中的所有信息都能在stu[i]中找到对应,i符合。
num++;
ans[ num] = i;
}
}
if ( num!= 1 ) {
} else {
output( ans[ 1 ] ) ;
}
}
return 0 ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPG1hdGguaD4KI2luY2x1ZGUgPHN0cmluZy5oPgojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIGluZiAweDNmM2YzZjNmCiNkZWZpbmUgbWluYyhhLGIpICgoKGEpPChiKSkgPyAoYSkgOiAoYikpCiNkZWZpbmUgbWF4YyhhLGIpICgoKGEpPihiKSkgPyAoYSkgOiAoYikpCmludCByZWFkKCl7CglpbnQgcmV0PTAsdHR0PTE7CgljaGFyIGNoPWdldGNoYXIoKTsKCXdoaWxlKGNoPCcwJyB8fCBjaD4nOScpewoJCWlmKGNoPT0nLScpewoJCQl0dHQ9LTE7CgkJfWNoPWdldGNoYXIoKTsKCX13aGlsZShjaD49JzAnICYmIGNoPD0nOScpewoJCXJldD0ocmV0PDwxKSsocmV0PDwzKSsoY2heNDgpOwoJCWNoPWdldGNoYXIoKTsKCX1yZXR1cm4gcmV0KnR0dDsKfQpzdHJ1Y3QgaW5mb3sKICAgIGNoYXIgbmFtZVszNV0sbm9bMzVdLGJwWzM1XSxhZ2VbNV0sc2V4WzM1XTsKfTsKc3RydWN0IGluZm8gc3R1WzEzMF07Ci8vdHJhbiDotJ/otKPmioror7vlhaXnmoTmlbTooYzlrZfnrKbkuLLmlq3miJDlsI/pg6jliIbotYvlgLznu5nnm67moIflr7nosaHjgILlj4LmlbBz5Li66K+75YWl55qE5pW06KGM5a2X56ym5Liy77yMdGFy5Li655uu5qCH5a+56LGh77yMaeS4uuiuoeaVsOWZqO+8jGzkuLrmlbTooYzplb/luqbjgIIKdm9pZCB0cmFuKGNoYXIgKnMsIGNoYXIgKnRhciwgaW50ICppLCBpbnQgbCl7CiAgICBpbnQgY250PTA7CiAgICAvL3ByaW50ZigiJXMgJWRcbiIscyxsKTsKICAgIGZvcig7ICgqaSk8bDsgKCppKSsrKXsKICAgICAgICAvL3ByaW50ZigiJWQgJWMiLCppLHNbKmldKTsKICAgICAgICBpZihzWyppXT09JywnKSBicmVhazsKICAgICAgICB0YXJbY250XT1zWyppXTsKICAgICAgICBjbnQrKzsKICAgIH0KICAgIC8vcHJpbnRmKCJcbiIpOwogICAgdGFyW2NudF09J1wwJzsKICAgIHJldHVybjsKfQp2b2lkIGlucHV0KGludCB4KXsKICAgIGNoYXIgc1syMDBdOwogICAgZ2V0cyhzKTsKICAgIGludCBsPXN0cmxlbihzKSxpbmQ9MDsKICAgIHRyYW4ocyxzdHVbeF0ubmFtZSwmaW5kLGwpOwogICAgaW5kKz0yOwogICAgdHJhbihzLHN0dVt4XS5ubywmaW5kLGwpOwogICAgaW5kKz0yOwogICAgdHJhbihzLHN0dVt4XS5icCwmaW5k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MF07CiAgICBpbnQgbDsKICAgIHdoaWxlKDEpewogICAgICAgIGdldHMocyk7CiAgICAgICAgbD1zdHJsZW4ocyk7CiAgICAgICAgaWYobD49NCl7CiAgICAgICAgICAgIGlmKHNbMF09PSdxJyAmJiBzWzFdPT0ndScgJiYgc1syXT09J2knICYmIHNbM109PSd0JykgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGludCBpbmQ9MCxjbnQ9MDsKICAgICAgICB3aGlsZShpbmQ8bCl7CiAgICAgICAgICAgIGNudCsrOwogICAgICAgICAgICB0cmFuKHMsYVtjbnRdLCZpbmQsbCk7CiAgICAgICAgICAgIC8vcHJpbnRmKCIlcyAiLGFbY250XSk7CiAgICAgICAgICAgIGluZCsrOwogICAgICAgIH0KICAgICAgICAvL3ByaW50ZigiXG4iKTsKICAgICAgICBpbnQgYW5zWzEzMF0sbnVtPTA7CiAgICAgICAgZm9yKGludCBpPTE7IGk8PW47IGkrKyl7CiAgICAgICAgICAgIGludCBmPTE7CiAgICAgICAgICAgIGZvcihpbnQgaj0xOyBqPD1jbnQ7IGorKyl7CiAgICAgICAgICAgICAgICBmPWYgJiYgY2hrKGosaSxhKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZihmKXsKICAgICAgICAgICAgICAgIC8vZj09MSDku6Pooajor7fmsYLkuK3nmoTmiYDmnInkv6Hmga/pg73og73lnKhzdHVbaV3kuK3mib7liLDlr7nlupTvvIxp56ym5ZCI44CCCiAgICAgICAgICAgICAgICBudW0rKzsKICAgICAgICAgICAgICAgIGFuc1tudW1dPWk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYobnVtIT0xKXsKICAgICAgICAgICAgcHJpbnRmKCJlcnJvclxuIik7CiAgICAgICAgfWVsc2V7CiAgICAgICAgICAgIG91dHB1dChhbnNbMV0pOwogICAgICAgIH0KICAgIH0KCXJldHVybiAwOwp9
stdout
Yang Yang, 201701199, Beijing, 18, male
Meng Meng, 201701222, Sichuan, 19, male
Tian Tian, 201701666, Shanghai, 19, female
Yang Yang, 201701199, Beijing, 18, male
Tian Tian, 201701666, Shanghai, 19, female
Yang Yang, 201701199, Beijing, 18, male
error
Tian Tian, 201701666, Shanghai, 19, female
Meng Meng, 201701222, Sichuan, 19, male
Tian Tian, 201701666, Shanghai, 19, female
Meng Meng, 201701222, Sichuan, 19, male