70,033
社区成员
发帖
与我相关
我的任务
分享
#include<stdio.h> /*提交的时候说我答案错误,我都改了14遍了,还是错误,高手们帮我看看把*/
#include<string.h>
struct s
{
char name[100]; /*大家帮我改好了可以去上面这个网址提交一下,帐号:csdn.密码:111111*/
int num;
};
int main()
{
int n,i,k,h,j;
char str[100];
static struct s a[1005];
while(scanf("%d",&n)!=EOF)
{
for(i=1;i<=n;i++)
{
scanf("%s%d",str,&j);
strcpy(a[j].name,str);
}
scanf("%d",&k);
for(i=0;i<k;i++)
{
scanf("%d",&h);
if(h>n)
printf("void\n");
else
printf("%s\n",a[h].name);
}
printf("\n");
}
return 0;
}
#include <stdio.h>
#include <string.h>
static char person_set[1001][65];
int
main() {
int N, n;
char name[65];
int id;
int K;
int x;
strcpy(person_set[0], "void");
scanf("%d", &N);
n = N;
while (n-- != 0) {
scanf("%s %d", name, &id);
strcpy(person_set[id], name);
}
scanf("%d", &K);
while (K-- != 0) {
scanf("%d", &x);
if (x > N)
x = 0;
printf("%s\n", person_set[x]);
}
return (0);
}
//哦是我看错了,trick只有一个,name中有空格,所以需要gets
//还要注意就是case之间才有空行
#include<stdio.h> /*提交的时候说我答案错误,我都改了14遍了,还是错误,高手们帮我看看把*/
#include<string.h>
struct s
{
char name[100]; /*大家帮我改好了可以去上面这个网址提交一下,帐号:csdn.密码:111111*/
int num;
};
int main()
{
int n,i,k,h,j,v;
char str[100];
static struct s a[1005];
int curr = 1;
while(scanf("%d",&n)!=EOF)
{
while (getchar() != '\n');
if (curr++ > 1) puts("");
for(i=1;i<=n;i++)
{
gets(str);
j = strlen(str) - 1;
while (str[j] != ' ') --j;
str[j] = 0;
sscanf(str+j+1, "%d", &v);
strcpy(a[v].name,str);
}
scanf("%d",&k);
for(i=0;i<k;i++)
{
scanf("%d",&h);
if(h>n)
printf("void\n");
else
printf("%s\n",a[h].name);
}
}
return 0;
}