| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
scanf("%d",&n)之后要用getchar()来清除回车,否则你的输入数据会少一组In Reply To:这两种写法到底有什么区别啊?//前的读入方式wa,改成//后的就ac了 Posted by:suibian at 2005-10-13 16:01:58 > #include "stdio.h"
> #include "string.h"
>
> typedef struct Node
> {
> char name[100];
> char part[100];
> int c;
> }node;
>
> int cmp(const node *x,const node *y)
> {
> return y->c-x->c;
> }
>
> int main()
> {
> int m,n;
> int i,j;
>
> char g[100];
> char ch[100];
> node f[30];
>
> for(i=0;i<30;++i)
> f[i].c=0;
> scanf("%d",&n);getchar(); //scanf("%d\n",&n);
> for(i=0;i<n;i++)
> {
> gets(f[i].name);
> gets(f[i].part);
> }
>
> scanf("%d",&m);getchar(); //scanf("%d\n",&m);
> for(i=0;i<m;i++)
> {
> gets(g);
> strcpy(ch,g);
> for(j=0;j<n;j++)
> if(strcmp(ch,f[j].name)==0)
> {
> f[j].c++;
> break;
> }
> }
> qsort(f,n,sizeof(node),cmp);
> if(f[0].c==f[1].c) printf("tie");
> else if(strcmp(f[0].part,"independent")==0)
> printf("independent");
> else printf("%s",f[0].part);
> system("pause");
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator