1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| #include<stdio.h> #include<stdlib.h>
typedef struct node{ char name[11]; char birthday[11]; char sex; char num[17]; char phone[17]; struct node* next; }type;
void output(type* head,int N); type* input(int N);
int main(void) { type *head; int N; scanf("%d",&N); head=input(N); output(head,N); return 0; }
type* input(int N) { type *p,*q,*head; int i=0; p=q=(type*)malloc(sizeof(type)); for(i=0;i<N;i++) { scanf("%s %s %c %s %s\n",p->name,p->birthday,&(p->sex),p->num,p->phone); if(i==0) { head=p; } else { q->next=p; } q=p; p=(type*)malloc(sizeof(type)); } q->next=NULL; p->next=NULL; return head; }
void output(type* head,int N) { int K,i,j; scanf("%d",&K); int a[K]; type *q; for(i=0;i<K;i++) { scanf("%d",&a[i]); } for(i=0;i<K;i++) { if(a[i]<N&&a[i]>=0) { q=head; for(j=0;j<a[i];j++) { q=q->next; } printf("%s %s %s %c %s\n",q->name,q->num,q->phone,q->sex,q->birthday); } else { printf("Not Found\n"); } } }
|