#include <stdio.h> #include <string.h> #include <malloc.h> typedef struct node{ char name[20]; int height; int money; struct node *next; } NODE; NODE *creat(int n){ NODE *head,*p,*q; head = (node*)malloc(sizeof(node)); head->next = NULL; while(n!=0){ p = (node*)malloc(sizeof(node)); scanf("%s%d%d",p->name,&p->height,&p->money); if(head->next == NULL){ p->next = head->next; head->next = p; q = p; } else{ p->next = q->next; q->next = p; q = p; } n--; } return head; } char search(NODE *head){ int height,money,H=0,M=0; NODE *p,*q; q = p = head->next; while(p){ if(strcmp(p->name,"Suxiao") == 0){ height = p->height; money = p->money; } p = p->next; } while(q){ if(height < q->height) H++; if(money < q->money) M++; q = q->next; } if(H == M) printf("EQ\n"); else if(H < M) printf("HEIGHT\n"); else printf("MONEY\n"); return 0; } main(){ NODE *head; int x; scanf("%d",&x); head = creat(x); search(head); return 0; } /* Main.c: In function 'creat': Main.c:12:10: error: 'node' undeclared (first use in this function) head = (node*)malloc(sizeof(node)); ^ Main.c:12:10: note: each undeclared identifier is reported only once for each function it appears in Main.c:12:15: error: expected expression before ')' token head = (node*)malloc(sizeof(node)); ^ Main.c:15:13: error: expected expression before ')' token p = (node*)malloc(sizeof(node)); ^ Main.c: At top level: Main.c:57:1: warning: return type defaults to 'int' main(){ ^ */ |
Double click to view unformatted code.