zoj 2104 Let the Balloon Rise

来源:互联网 发布:云南网络广播电视直播 编辑:程序博客网 时间:2024/04/30 00:34
#include<stdio.h>#include<string.h>#include<stdlib.h>int main(){struct col{char ch[16];int num;struct col *next;} *head,*tail,*p,*q;int n,i,count,max;char str[16];char m[16];while(scanf("%d",&n)&&n){    head = tail = NULL;count = 0;while(n--){scanf("%s",str);max = 0;strcpy(m,str);for(q = head;q!=NULL;q = q->next){if(strcmp(str,q->ch) == 0) q->num++;if(n == 0&&q->num>max) {max = q->num;strcpy(m,q->ch);}}if(q == NULL){   p = (struct col *)malloc(sizeof(struct col));strcpy(p->ch,str);p->num = 0;p->next = NULL;if(head == NULL)head = p;else tail->next = p;tail = p;}}    printf("%s\n",m);}return 0;}

0 0
原创粉丝点击