label
stringlengths 1
2
| index
stringlengths 1
5
| code
stringlengths 87
8.24k
|
---|---|---|
14 | 6800 | struct info
{
int num;
int chin;
int math;
struct info *next;
};
struct info *create(int n)
{
int i;
struct info *head,*p1,*p2;
p1=(struct info*)malloc(sizeof(struct info));
scanf("%d %d %d",&p1->num,&p1->chin,&p1->math);
p1->next=NULL;
head=p1;
p2=p1;
i=1;
do
{
p1=(struct info*)malloc(sizeof(struct info));
scanf("%d %d %d",&p1->num,&p1->chin,&p1->math);
p1->next=NULL;
p2->next=p1;
p2=p1;
i++;
}while(i<n);
return(head);
}
void arrange(struct info *head)
{
int m,no1,no2,no3;
struct info *p;
p=head;
m=0;
while(p)
{
if (p->chin+p->math>m)
{m=p->chin+p->math;no1=p->num;}
p=p->next;
}
printf("%d %d\n",no1,m);
m=0;
p=head;
no2=p->num;
while(p)
{
if (p->chin+p->math>m&&p->num!=no1)
{m=p->chin+p->math;no2=p->num;}
p=p->next;
}
printf("%d %d\n",no2,m);
m=0;
p=head;
no3=p->num;
while(p)
{
if (p->chin+p->math>m&&p->num!=no1&&p->num!=no2)
{m=p->chin+p->math;no3=p->num;}
p=p->next;
}
printf("%d %d\n",no3,m);
}
int main()
{
int n;
struct info *head;
scanf("%d",&n);
head=create(n);
arrange(head);
}
|
14 | 6801 | void main()
{
long n;
scanf("%ld",&n);
struct student
{
int num;
int chi;
int math;
int sum;
}stu[100000];
int i;
for(i=0;i<n;i++)
{
scanf("%d %d %d",&stu[i].num,&stu[i].chi,&stu[i].math);
stu[i].sum=stu[i].chi+stu[i].math;
}
struct student blank;
for(i=0;i<n;i++)
{
if(stu[i].sum>stu[0].sum)
{
blank=stu[0];
stu[0]=stu[i];
stu[i]=blank;
}
}
for(i=1;i<n;i++)
{
if(stu[i].sum>stu[1].sum)
{
blank=stu[1];
stu[1]=stu[i];
stu[i]=blank;
}
}
for(i=2;i<n;i++)
{
if(stu[i].sum>stu[2].sum)
{
blank=stu[2];
stu[2]=stu[i];
stu[i]=blank;
}
}
for(i=0;i<=2;i++)
printf("%d %d\n",stu[i].num,stu[i].sum);
}
|
14 | 6802 | struct student
{int id;
int chinese;
int maths;
int total;
};
void main()
{
int n,i;
struct student s,s1,s2,s3;
scanf("%d",&n);
s2.total=s1.total=s3.total=-1;
for(i=0;i<n;i++)
{ scanf("%d %d %d",&s.id,&s.chinese,&s.maths);
s.total=s.chinese+s.maths;
if(s.total>s1.total)
{ s3=s2;
s2=s1;
s1=s;
}
else if(s.total>s2.total)
{ s3=s2;
s2=s;
}
else if(s.total>s3.total)
s3=s;
}
printf("%d %d\n",s1.id,s1.total);
printf("%d %d\n",s2.id,s2.total);
printf("%d %d\n",s3.id,s3.total);
} |
14 | 6803 | struct student
{
int num;
float yuwen;
float shuxue;
float zongfen;
}stu[student_num],*p[3];
void main()
{
void paixu(struct student *a,int n);
int i,n;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%f%f",&stu[i].num,&stu[i].yuwen,&stu[i].shuxue);
stu[i].zongfen=stu[i].yuwen+stu[i].shuxue;
}
paixu(stu,n);
for(i=0;i<3;i++)printf("%d %.0f\n",p[i]->num,p[i]->zongfen);
}
void paixu(struct student *a,int n)
{
int i,j;
float x[3];
for(i=0;i<3;i++)
{
for(j=1,p[i]=a;j<n;j++)if(p[i]->zongfen<(a+j)->zongfen)p[i]=a+j;
x[i]=p[i]->zongfen;
p[i]->zongfen=0;
}
for(i=0;i<3;i++)p[i]->zongfen=x[i];
} |
14 | 6804 | void main(int argc, char* argv[])
{
struct student
{
int No;
int chinese;
int math;
int total;
} stu[100000];
int i,j,x,y,z,n;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&stu[i].No);
scanf("%d",&stu[i].chinese);
scanf("%d",&stu[i].math);
stu[i].total=stu[i].chinese+stu[i].math;
}
for(j=0;j<3;j++){
x=0;
for(i=0;i<n;i++){
if( stu[i].total>x){
x=stu[i].total;
y=stu[i].No;
z=i;
}
}
printf("%d %d\n",y,x);
stu[z].total=0;
}
}
|
14 | 6805 | struct stud
{
int n;
int chinese;
int math;
int total;
struct stud *next;
};
int tol;
struct stud *creat(void)
{
struct stud *head,*p1,*p2;
int i=1;
p1=p2=(struct stud *)malloc(sizeof(struct stud));
head=p1;
for(i=1;i<tol;i++)
{
scanf("%d%d%d",&p1->n,&p1->chinese,&p1->math);
p1->total=(p1->math+p1->chinese);
p1=(struct stud *)malloc(sizeof(struct stud));
p2->next=p1;
p2=p1;
}
scanf("%d%d%d",&p1->n,&p1->chinese,&p1->math);
p1->total=(p1->math+p1->chinese);
p2->next=p1;
p1->next=0;
return head;//???????
}
int max(struct stud *head,int max1,int max2)
{
struct stud *p1;
int maxtotal=head->total,max_index;
for(p1=head;p1!=0;p1=p1->next)
{
if(p1->total>maxtotal&&p1->n!=max1&&p1->n!=max2)
{
maxtotal=(p1->total);
max_index=(p1->n);
}
}
if(maxtotal!=max1)
printf("%d %d\n",max_index,maxtotal);
return max_index;
}
void main()
{
struct stud *head;
int max1,max2;
scanf("%d",&tol);
head=creat();
max1=max(head,0,0);
max2=max(head,max1,0);
max(head,max1,max2);
}
|
14 | 6806 | int n;
struct stu
{
int xh;
int yw;
int sx;
int all;
struct stu*next;
};
struct stu *a,*b,*c,q,t,r;
struct stu*creat()
{
struct stu *head;
struct stu *p1,*p2;
int i;
p1=p2=(struct stu*)malloc(sizeof(struct stu));
scanf("%d%d%d",&p1->xh,&p1->yw,&p1->sx);
p1->all=p1->yw+p1->sx;
head=p1;
a=b=c=head;
for(i=1;i<n;i++)
{
p2->next=p1;
p2=p1;
p1=(struct stu*)malloc(sizeof(struct stu));
scanf("%d%d%d",&p1->xh,&p1->yw,&p1->sx);
p1->all=p1->yw+p1->sx;
if(p1->all>a->all)
{
c=b;
b=a;
a=p1;
}
else
if(p1->all>b->all)
{
c=b;
b=p1;
}
else
{
if(p1->all>c->all)
c=p1;
}
}p2->next=NULL;
return head;
}
void main()
{
struct stu *p;
a=&q;b=&t;c=&r;
scanf("%d",&n);
p=creat();
printf("%d %d\n%d %d\n%d %d\n",a->xh,a->all,b->xh,b->all,c->xh,c->all);
}
|
14 | 6807 | int main()
{
int n;
scanf ("%d",&n);
struct student
{
int num;
int chinese;
int maths;
};
struct student a[100000],temp;
int i;
for (i=0;i<n;i++)
{
scanf("%d",&a[i].num);
scanf("%d",&a[i].chinese);
scanf("%d",&a[i].maths);
}
for (i=1;i<n;i++)
{
if ((a[i].chinese+a[i].maths)>(a[0].chinese+a[0].maths))
{
temp=a[0];
a[0]=a[i];
a[i]=temp;
}
}
printf("%d %d\n",a[0].num,a[0].chinese+a[0].maths);
for (i=2;i<n;i++)
{
if ((a[i].chinese+a[i].maths)>(a[1].chinese+a[1].maths))
{
temp=a[1];
a[1]=a[i];
a[i]=temp;
}
}
printf("%d %d\n",a[1].num,a[1].chinese+a[1].maths);
for (i=3;i<n;i++)
{
if ((a[i].chinese+a[i].maths)>(a[2].chinese+a[2].maths))
{
temp=a[2];
a[2]=a[i];
a[i]=temp;
}
}
printf("%d %d\n",a[2].num,a[2].chinese+a[2].maths);
return 0;
}
|
14 | 6808 | int n;
struct student
{
int num;
int chinese;
int math;
int total;
struct student *next;
};
struct student *creat(int n)
{
struct student *head;
struct student *p1,*p2;
int i;
if(n==0)
{
head=NULL;
return(head);
}
else
{
p1=(struct student*)malloc(LEN);
scanf("%d %d %d",&p1->num,&p1->chinese,&p1->math);
p1->next=NULL;
head=p1;
p2=p1;
for(i=1;i<n;i++)
{
p1=(struct student*)malloc(LEN);
scanf("%d %d %d",&p1->num,&p1->chinese,&p1->math);
p1->next=NULL;
p2->next=p1;
p2=p1;
}
return(head);
}
}
void top3(struct student *head)
{
struct student *p,*p1;
int max=0;
p=head;
do
{
p->total=(p->chinese)+(p->math);
if((p->total)>max)
{
max=p->total;
p1=p;
}
p=p->next;
}while(p!=NULL);
printf("%d %d\n",p1->num,p1->total);
p1->total=0;
p=head;
max=0;
do
{
if((p->total)>max)
{
max=p->total;
p1=p;
}
p=p->next;
}while(p!=NULL);
printf("%d %d\n",p1->num,p1->total);
p1->total=0;
p=head;
max=0;
do
{
if((p->total)>max)
{
max=p->total;
p1=p;
}
p=p->next;
}while(p!=NULL);
printf("%d %d\n",p1->num,p1->total);
p1->total=0;
max=0;
}
void main()
{
struct student *head;
scanf("%d",&n);
head=creat(n);
top3(head);
} |
14 | 6809 | int main(int argc, char* argv[])
{
struct r{int a;int b;int c;}r[99999];
int i,n,x=0,y=0,z=0,m1=0,m2=0,m3=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d%d%d",&r[i].a,&r[i].b,&r[i].c);
}
for(i=1;i<=n;i++)
{
if(r[i].b+r[i].c>m1)
{
m1=r[i].b+r[i].c;
x=i;
}
}
for(i=1;i<=n;i++)
{
if((r[i].b+r[i].c==m1)&&(i!=x))
{
m2=r[i].b+r[i].c;
y=i;
}
else if((m1>r[i].b+r[i].c)&&(r[i].b+r[i].c>m2))
{
m2=r[i].b+r[i].c;
y=i;
}
}
for(i=1;i<=n;i++)
{
if((r[i].b+r[i].c==m2)&&(i!=y)&&(i!=x))
{
m3=r[i].b+r[i].c;
z=i;
}
else if((m2>r[i].b+r[i].c)&&(r[i].b+r[i].c>m3))
{
m3=r[i].b+r[i].c;
z=i;
}
}
printf("%d %d\n",x,m1);
printf("%d %d\n",y,m2);
printf("%d %d\n",z,m3);
return 0;
}
|
14 | 6810 | struct stu
{
int num;
int ch;
int math;
struct stu* next;
};
void main()
{
int n,m=0,max=0,max2=0,max3=0,no=0,no2=0,no3=0;
struct stu*p;
scanf("%d",&n);
struct stu*p1,*p2,*head;
p1=(struct stu*)malloc(LEN);
scanf("%d%d%d",&p1->num,&p1->ch,&p1->math);
head=NULL;
while(n-1)
{
m=m+1;
if(m==1)
head=p1;
else
p2->next=p1;
p2=p1;
p1=(struct stu*)malloc(LEN);
scanf("%d%d%d",&p1->num,&p1->ch,&p1->math);
n--;
}
p2->next=NULL;
p=head;
while(p)
{
p->ch=p->math+p->ch;
p=p->next;
}
p=head;
while(p)
{
if(p->ch>max)
{
max=p->ch;
no=p->num;
}
p=p->next;
}
printf("%d %d\n",no,max);
p=head;
while(p)
{
if(p->ch<=max&&p->ch>max2&&p->num!=no)
{
max2=p->ch;
no2=p->num;
}
p=p->next;
}
printf("%d %d\n",no2,max2);
p=head;
while(p)
{
if(p->ch<=max2&&p->ch>max3&&p->num!=no&&p->num!=no2)
{
max3=p->ch;
no3=p->num;
}
p=p->next;
}
printf("%d %d",no3,max3);
} |
14 | 6811 |
int main()
{
int n,i,j,k;
struct student
{
int num;
int chi;
int math;
int sum;
}score[100000],temp;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d %d %d",&score[i].num,&score[i].chi,&score[i].math);
score[i].sum=score[i].chi + score[i].math;
}
for(i=0;i<4;i++)
{
k=i;
for(j=i+1;j<n;j++)
if(score[j].sum>score[k].sum) k=j;
temp=score[k];score[k]=score[i];score[i]=temp;
}
printf("%d %d",score[0].num,score[0].sum);printf("\n");
printf("%d %d",score[1].num,score[1].sum);printf("\n");
printf("%d %d",score[2].num,score[2].sum);
return 0;
} |
14 | 6812 | int main()
{
int i,t=0,c=1,d=1,n,p=0,q=0,r=0,*b;
struct pp
{
int x;
int y;
int z;
}*s;
scanf("%d",&n);
b=(int*)malloc(sizeof(int)*n);
s=(struct pp*)malloc(sizeof(int)*3*n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&s[i].x,&s[i].y,&s[i].z);
b[i]=((s[i].y)+(s[i].z));
}
for(i=0;i<n;i++)
{
if(b[i]>t)
{
t=b[i];
p=i;
}
}
for(i=0;i<n;i++)
{
{
if((b[i]>c)&&(i!=p))
{c=b[i];
q=i;}
}
}
for(i=0;i<n;i++)
{
{
if((b[i]>d)&&(i!=p)&&(i!=q))
{d=b[i];
r=i;}
}
}
printf("%d %d\n",s[p].x,b[p]);
printf("%d %d\n",s[q].x,b[q]);
printf("%d %d\n",s[r].x,b[r]);
return 0;
}
|
14 | 6813 |
struct statistics
{
int num;
int chinese;
int math;
int sum;
} form[100000],temp;
int main()
{
int n;
scanf("%d",&n);
int i,j;
for(i=0;i<n;i++)
{
scanf("%d %d %d",&form[i].num,&form[i].chinese,&form[i].math);
form[i].sum=form[i].chinese+form[i].math;
}
for(i=0;i<3&&i<n-1;i++)
{
int k=i;
for(j=i+1;j<n;j++)
{
if(form[j].sum>form[k].sum)
{
k=j;
}
}
if (k!=i)
{
temp=form[i];
form[i]=form[k];
form[k]=temp;
}
}
for(i=0;i<3;i++)
printf("%d %d\n",form[i].num,form[i].sum);
return 0;
} |
14 | 6814 | struct info
{
char num[10];
int chn;
int math;
struct info *next;
};
int n,all;
struct info *setup(void)
{
struct info *head,*p1,*p2;
n=0;
while(n<all)
{
p1=(struct info*)malloc(sizeof(struct info));
scanf("%s %d %d",p1->num,&p1->chn,&p1->math);
n+=1;
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
}
p2->next=NULL;
return(head);
}
void main()
{
struct info *p;
int i,first=0,second=0,third=0;
char fnum[10],snum[10],tnum[10];
scanf("%d",&all);
p=setup();
do
{
if(TOTAL>first)
{
third=second;
second=first;
first=TOTAL;
strcpy(tnum,"");
strcat(tnum,snum);
strcpy(snum,"");
strcat(snum,fnum);
strcpy(fnum,"");
strcat(fnum,p->num);
}
else if(TOTAL>second)
{
third=second;
second=TOTAL;
strcpy(tnum,"");
strcat(tnum,snum);
strcpy(snum,"");
strcat(snum,p->num);
}
else if(TOTAL>third)
{
third=TOTAL;
strcpy(tnum,"");
strcat(tnum,p->num);
}
p=p->next;
}while(p!=NULL);
printf("%s %d\n%s %d\n%s %d\n",fnum,first,snum,second,tnum,third);
} |
14 | 6815 | struct stud
{
int num;
int score,score1,score2;
struct stud *next;
}head,end;
void create(int n)
{
int i;
struct stud *p1,*p2;
head.next=NULL;
for (i=0;i<=n-1;i++)
{
p1=(struct stud *)malloc(sizeof(struct stud));
if (!i) head.next=p1;
else p2->next=p1;
scanf("%d",&p1->num);
scanf("%d",&p1->score1);
scanf("%d",&p1->score2);
p1->score=p1->score1+p1->score2;
p2=p1;
}
p2->next=&end;
}
void find()
{
struct stud *max1,*max2,*max3,*p1,*swap; //max1 is the max
max1=head.next;
max2=max1->next;
max3=max2->next;
p1=max3->next;
if ( max1->score < max2->score )
{
swap=max1;
max1=max2;
max2=swap;
}
if ( max2->score < max3->score )
{
swap=max2;
max2=max3;
max3=swap;
}
if ( max1->score < max2->score )
{
swap=max1;
max1=max2;
max2=swap;
}
while (p1!=&end)
{
if ( p1->score > max3->score ) max3=p1;
if ( max3->score > max2->score )
{
swap=max3;
max3=max2;
max2=swap;
}
if ( max2->score > max1->score )
{
swap=max1;
max1=max2;
max2=swap;
}
p1=p1->next;
}
printf("%d %d\n",max1->num,max1->score);
printf("%d %d\n",max2->num,max2->score);
printf("%d %d\n",max3->num,max3->score);
}
void main()
{
int n;
scanf("%d",&n);
create(n);
find();
}
|
14 | 6816 | int main()
{
int n,a[100000],b[100000],c[100000],sum[100000],i,t1,t2,t3,s1,s2,s3;
scanf("%d",&n);
for(i=0;i<n;i++)
{scanf("%d%d%d",&a[i],&b[i],&c[i]);
sum[i]=b[i]+c[i];}
for(i=0,t1=0,s1=a[0];i<n;i++)
{if(sum[i]>t1)
{t1=sum[i];
s1=a[i];}}
printf("%d %d\n",s1,t1);
for(i=0,t2=0,s2=a[0];i<n;i++)
{if(a[i]==s1)continue;
if(sum[i]>t2)
{t2=sum[i];
s2=a[i];}}
printf("%d %d\n",s2,t2);
for(i=0,t3=0,s3=a[0];i<n;i++)
{if(a[i]==s1||a[i]==s2)continue;
if(sum[i]>t3)
{t3=sum[i];
s3=a[i];}}
printf("%d %d\n",s3,t3);
return 0;
}
|
14 | 6817 | struct stu
{
int num;
int chinese;
int math;
int sum;
struct stu *next;
};
void main()
{
void max(struct stu*);
int n,i;
struct stu *p,*q,*head;
scanf("%d\n",&n);
head=(struct stu*)malloc(sizeof(struct stu));
p=(struct stu*)malloc(sizeof(struct stu));
head->next=p;
for(i=0;i<n;i++)
{
scanf("%d %d %d",&p->num,&p->chinese,&p->math);
p->sum=p->chinese+p->math;
q=(struct stu*)malloc(sizeof(struct stu));
p->next=q;
p=q;
}
p->next=NULL;
max(head);
max(head);
max(head);
}
void max(struct stu*head)
{
struct stu *p,*k,*r,*q;
int max=0;
p=head;
while(p->next!=NULL)
{
r=p;
p=p->next;
if(p->sum>max) max=p->sum,k=r,q=p;
}
printf("%d %d\n",q->num,q->sum);
k->next=q->next;
free(q);
}
|
14 | 6818 |
int main(){
struct student{ //????student
int StudentNumber; //??
int ChineseGrades; //????
int MathGrades; //????
int Total; //???
};
struct student Stu[100000],sTemp; //??????Stu?sTemp
int n,i,j; //n??????i?j?????
cin>>n; //??????
for (i=0;i<=n-1;i++){ //????????????????????????
cin>>Stu[i].StudentNumber>>Stu[i].ChineseGrades>>Stu[i].MathGrades;
Stu[i].Total=Stu[i].ChineseGrades+Stu[i].MathGrades;
}
for (i=0;i<=2;i++){ //?????????????????????
for (j=n-1;j>=i+1;j--){
if (Stu[j].Total>Stu[j-1].Total){
sTemp=Stu[j];
Stu[j]=Stu[j-1];
Stu[j-1]=sTemp;
}
}
}
cout<<Stu[0].StudentNumber<<" "<<Stu[0].Total; //?????
for (i=1;i<=2;i++){
cout<<endl;
cout<<Stu[i].StudentNumber<<" "<<Stu[i].Total;
}
return 0;
}
|
14 | 6819 | struct student
{
int num;
int sum;
}stu[100000];
int main()
{
int n,i,j,t,a,b,m;
int tempSum;
int tempMax;
int rank[3]={0};
scanf("%d",&n);
//struct student * stu;
//stu = (struct student *)malloc(sizeof(struct student) * n);
for(i=0;i<n;i++)
{
tempSum = 0;
scanf("%d",&stu[i].num);
stu[i].sum = 0;
for(j=0;j<2;j++){
scanf("%d",&tempSum);
stu[i].sum += tempSum;
}
}
for(b=0;b<3;b++)
{
tempMax = 0;
for(a=b;a<n;a++)
{
if(stu[a].sum > tempMax){
tempMax = stu[a].sum;
rank[b] = a;
}
}
t = stu[b].num;
stu[b].num = stu[rank[b]].num;
stu[rank[b]].num = t;
t = stu[b].sum;
stu[b].sum = stu[rank[b]].sum;
stu[rank[b]].sum = t;
}
for(a=0;a<3;a++)
printf("%d %d\n",stu[a].num,stu[a].sum);
return 0;
}
|
14 | 6820 | struct stu
{
float num;
float chi,mat,total;
struct stu *next;
};
struct stu *creat(int n)
{
int i;
struct stu *head,*p1,*p2;
for(i=0;i<n;i++)
{
p1=(struct stu*)malloc(sizeof(struct stu));
scanf("%f %f %f",&p1->num,&p1->chi,&p1->mat);
p1->total=p1->chi+p1->mat;
if (i==0)
{head=p2=p1;}
else
{p2->next=p1;p2=p1;}
}
p2->next=0;
return(head);
}
void main()
{
int n,i,j;
float max;
struct stu *head,*maxi,*p;
scanf("%d",&n);
head=creat(n);
for(i=0;i<3;i++)
{
p=head;maxi=head;
max=head->total;
for(j=0;j<n-1;j++)
{
p=p->next;
if(p->total>max)
{max=p->total;maxi=p;}
}
printf("%g %g\n",maxi->num,maxi->total);
maxi->total=0;
}
}
|
14 | 6821 | void main()
{
struct student
{
int num,sum;
} stu[100000];
int n,i,j,k,a,b,t;
scanf("%d",&n);
for (i=0;i<n;i++)
{
scanf("%d %d %d",&stu[i].num,&a,&b);
stu[i].sum=a+b;
}
for (i=0;i<3;i++)
for (j=n-i-1;j>0;j--)
if (stu[j].sum>stu[j-1].sum)
{
t=stu[j].sum;stu[j].sum=stu[j-1].sum;stu[j-1].sum=t;
t=stu[j].num;stu[j].num=stu[j-1].num;stu[j-1].num=t;
}
for (i=0;i<3;i++) printf("%d %d\n",stu[i].num,stu[i].sum);
} |
14 | 6822 | struct Student
{
long id;
int chn;
int mth;
int total;
};
void main()
{
struct Student *p1,*top1,*top2,*top3,*temp;
int i;
long int n;
scanf("%ld",&n);
top1=(struct Student*)malloc(sizeof(struct Student));
top2=(struct Student*)malloc(sizeof(struct Student));
top3=(struct Student*)malloc(sizeof(struct Student));
temp=(struct Student*)malloc(sizeof(struct Student));
scanf("%d %d %d",&top1->id,&top1->chn,&top1->mth);
top1->total=top1->chn + top1->mth;
scanf("%d %d %d",&top2->id,&top2->chn,&top2->mth);
top2->total=top2->chn + top2->mth;
if(top2->total>top1->total)
{
temp=top2;
top2=top1;
top1=temp;
}
scanf("%d %d %d",&top3->id,&top3->chn,&top3->mth);
top3->total=top3->chn + top3->mth;
if(top3->total>top2->total)
{
temp=top3;
top3=top2;
top2=temp;
}
if(top2->total>top1->total)
{
temp=top2;
top2=top1;
top1=temp;
}
for(i=3;i<n;i++)
{
p1=(struct Student*)malloc(sizeof(struct Student));
scanf("%d %d %d",&p1->id,&p1->chn,&p1->mth);
p1->total=p1->chn + p1->mth;
if (top1->total< p1->total) {top3=top2;top2=top1;top1=p1;continue;}
if (top2->total< p1->total) {top3=top2;top2=p1;continue;}
if (top3->total< p1->total) {top3=p1;continue;}
free (p1);
}
printf("%d %d\n%d %d\n%d %d\n",top1->id,top1->total,top2->id,top2->total,top3->id,top3->total);
} |
14 | 6823 |
struct student
{
int id;
int math;
int chinese;
int sum;
}stu[100000];
int main(int argc, char* argv[])
{
int i , n ;
int max1=0,max2=0,max3=0;
int maxid1=0,maxid2=0,maxid3=0;
scanf("%d", &n );
for ( i = 0 ; i < n ; i ++ )
{
scanf("%d %d %d", &stu[i].id , &stu[i].chinese ,&stu[i].math );
stu[i].sum = stu[i].math + stu[i].chinese;
if ( stu[i].sum > max1 )
{
max3 = max2 ;
max2 = max1 ;
max1 = stu[i].sum ;
maxid3 = maxid2 ;
maxid2 = maxid1 ;
maxid1 = stu[i].id;
}
else if ( stu[i].sum > max2 )
{
max3 = max2 ;
max2 = stu[i].sum ;
maxid3 = maxid2 ;
maxid2 = stu[i].id ;
}
else if ( stu[i].sum > max3 )
{
max3 = stu[i].sum ;
maxid3 = stu[i].id ;
}
}
printf("%d %d\n%d %d\n%d %d" , maxid1,max1,maxid2,max2,maxid3,max3);
return 0;
}
|
14 | 6824 | struct stu
{
int num;
int yu;
int shu;
int tol;
struct stu *next;
};
int n;
struct stu *creat(void)
{
struct stu *p1,*p2,*head,*p;
int i,k;
p1=p2=(struct stu *)malloc(sizeof(struct stu));
scanf("%d %d %d",&p1->num,&p1->yu,&p1->shu);
p1->tol=p1->yu+p1->shu;
p1->next=0;
head=p1;
p=p1;
p1=(struct stu *)malloc(sizeof(struct stu));
for(i=1;i<n;i++)
{
p=head;
p2=p1;
k=0;
scanf("%d %d %d",&p1->num,&p1->yu,&p1->shu);
p1->tol=p1->yu+p1->shu;
while(p!=0&&p->tol>=p1->tol)
{
p2=p;
p=p->next;
k++;
}
if(k<=3)
{
if(p==head)
{
head=p1;
p1->next=p;
}
if(p==0)
{
p2->next=p1;
p1->next=0;
}
if(p!=head&&p!=0)
{
p2->next=p1;
p1->next=p;
}
}
p1=(struct stu *)malloc(sizeof(struct stu));
}
return head;
}
void main()
{
struct stu *head,*p;
int i=0;
scanf("%d",&n);
head=creat();
p=head;
while(i<3)
{
printf("%d %d\n",p->num,p->tol);
i++;
p=p->next;
}
} |
14 | 6825 | int main()
{
int i,n,math,chinese,std_num;
int first,second,third;
int score[3]={-1,-1,-1};
scanf("%d",&n);
first=0;second=0;third=0;
for(i=0;i<n;i++){
scanf("%d",&std_num);
scanf("%d",&chinese);
scanf("%d",&math);
if (chinese+math>score[0]){
third =second;
second=first;
score[2]=score[1];
score[1]=score[0];
first = std_num;
score[0]=chinese+math;
}
else if(chinese+math>score[1]){
third=second;
score[2]=score[1];
second=std_num;
score[1]=math+chinese;
}
else if(chinese+math>score[2]){
third=std_num;
score[2]=math+chinese;
}
}
printf("%d %d\n",first,score[0]);
printf("%d %d\n",second,score[1]);
printf("%d %d\n",third,score[2]);
return 0;
}
|
14 | 6826 | struct student
{
long num;
int chi;
int math;
int add;
};
struct student stu[100000];
void main()
{
int m,k,n,i,j;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%ld %d %d",&stu[i].num,&stu[i].chi,&stu[i].math);
stu[i].add=stu[i].chi+stu[i].math;
}
for(j=0;j<3;j++)
for(i=n-1;i>0;i--)
{
if(stu[i].add>stu[i-1].add)
{
k=stu[i].add;stu[i].add=stu[i-1].add;stu[i-1].add=k;
m=stu[i].num;stu[i].num=stu[i-1].num;stu[i-1].num=m;
}
}
for(i=0;i<3;i++)
printf("%ld %d\n",stu[i].num,stu[i].add);
}
|
14 | 6827 | main()
{
int i,n,t[3]={0},u[3]={0};
struct student
{
long int ID;
int math;
int chinese;
int a;
}stu[100000];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d %d %d",&stu[i].ID,&stu[i].math,&stu[i].chinese);
stu[i].a=stu[i].math+stu[i].chinese;
}
for(i=0;i<n;i++)
{
if(stu[i].a>t[0])
{t[0]=stu[i].a;u[0]=i;}
}
for(i=0;i<n;i++)
{
if(i==u[0])continue;
if(stu[i].a>t[1])
{t[1]=stu[i].a;u[1]=i;}
}
for(i=0;i<n;i++)
{
if(i==u[0]||i==u[1])continue;
if(stu[i].a>t[2])
{t[2]=stu[i].a;u[2]=i;}
}
printf("%d %d\n%d %d\n%d %d\n",stu[u[0]].ID,t[0],stu[u[1]].ID,t[1],stu[u[2]].ID,t[2]);
} |
14 | 6828 | int main()
{
struct student
{
int num;
int chinese;
int math;
int sum;
}stu[100000],t;
int n;
int i;
int k;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d %d",&stu[i].num,&stu[i].chinese,&stu[i].math);
stu[i].sum=stu[i].chinese+stu[i].math;
}
for(k=n-1;k>n-4;k--){
for(i=0;i<k;i++){
if(stu[i].sum>=stu[i+1].sum){
t=stu[i];
stu[i]=stu[i+1];
stu[i+1]=t;
}
}
}
printf("%d %d\n",stu[n-1].num,stu[n-1].sum);
printf("%d %d\n",stu[n-2].num,stu[n-2].sum);
printf("%d %d\n",stu[n-3].num,stu[n-3].sum);
return 0;
}
|
14 | 6829 | int main()
{
int n,i,max1=0,max2=0,max3=0,t1=0,t2=0,t3=0;
int ID[100000],y[100000],m[100000],s[100000];
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d %d %d",&ID[i],&y[i],&m[i]);
for(i=0;i<n;i++)
s[i]=y[i]+m[i];
for(i=0;i<n;i++)
{
if(max1<s[i])
{
max1=s[i];
t1=i;
}
}
s[t1]=0;
for(i=0;i<n;i++)
{
if(max2<s[i])
{
max2=s[i];
t2=i;
}
}
s[t2]=0;
for(i=0;i<n;i++)
{
if(max3<s[i])
{
max3=s[i];
t3=i;
}
}
printf("%d %d\n",ID[t1],max1);
printf("%d %d\n",ID[t2],max2);
printf("%d %d\n",ID[t3],max3);
getchar();
getchar();
getchar();
return 0;
}
|
14 | 6830 |
struct student{
int No;
int yuwen;
int shuxue;
int sum;
};
int main(){
int n,i,k,e,f;
scanf("%d",&n);
struct student *stu=(struct student*)malloc(sizeof(int)*4*n);
for(i=0;i<n;i++){
scanf("%d%d%d",&stu[i].No,&stu[i].yuwen,&stu[i].shuxue);
stu[i].sum=stu[i].yuwen+stu[i].shuxue;
}
for(k=0;k<3;k++){
for(i=n-1;i>k;i--){
if(stu[i-1].sum<stu[i].sum){
e=stu[i-1].sum;
stu[i-1].sum=stu[i].sum;
stu[i].sum=e;
f=stu[i-1].No;
stu[i-1].No=stu[i].No;
stu[i].No=f;
}
}
}
for(i=0;i<3;i++){
printf("%d %d\n",stu[i].No,stu[i].sum);
}
return 0;
}
|
14 | 6831 |
int main()
{
int a[3], n,c,b,d,g[3], i,temp;
int j = 0;
scanf("%d",&n);
for(i = 0; i < 3; i++)
{
scanf("%d %d %d", &d,&b,&c);
g[i] = d;
a[i] = b+c;
}
for (i = 0; i < 3 - 1; i++)
for (j = 0; j < 3 - 1 - i; j++)
if (a[j] < a[j+1]) {
temp = a[j] ;
a[j] = a[j+1];
a[j+1] = temp;
temp = g[j];
g[j] = g[j+1];
g[j+1] = temp;
}
for(i=3;i<n;i++)
{
scanf("%d %d %d",&d,&b,&c);
temp=b+c;
if(temp <= a[2])
{
continue;
} else {
if (a[1] >= temp){
a[2] = temp;
g[2]=d;
}
else {
a[2] = a[1];
g[2]=g[1];
if(a[0] >=temp){
a[1]=temp;
g[1]=d;
}
else {
a[1]=a[0];
g[1]=g[0];
a[0]=temp;
g[0]=d;
}
}
}
}
printf("%d %d\n%d %d\n%d %d\n",g[0],a[0],g[1],a[1],g[2],a[2]);
} |
14 | 6832 | struct student
{
int id;
int score1;
int score2;
struct student *next;
};
struct student *head;
struct student *creat(int x)
{
struct student *p1,*p2;
p1=p2=(struct student *)malloc(LEN);
scanf("%d %d %d",&p1->id,&p1->score1,&p1->score2);
head=0;
while(p1->id<x)
{
if(p1->id==1)
head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(LEN);
scanf("%d %d %d",&p1->id,&p1->score1,&p1->score2);
if(p1->id==x){
p2->next=p1;
p2=p1;
}
}
p2->next=0;
return(head);
}
void main()
{
int n;
struct student *p,*q,*j,*k;
scanf("%d",&n);
creat(n);
p=q=head;
do{
if((p->score1+p->score2)>(q->score1+q->score2))
q=p;
p=p->next;
}while(p!=0);
p=j=head;
do{
if((p->score1+p->score2)>(j->score1+j->score2)&&p!=q)
j=p;
p=p->next;
}while(p!=0);
p=k=head;
do{
if((p->score1+p->score2)>(k->score1+k->score2)&&p!=q&&p!=j)
k=p;
p=p->next;
}while(p!=0);
printf("%d %d\n",q->id,(q->score1+q->score2));
printf("%d %d\n",j->id,(j->score1+j->score2));
printf("%d %d",k->id,(k->score1+k->score2));
} |
14 | 6833 | int main()
{
int n;
scanf("%d\n",&n);
struct student{
int id;
int yu,shu;
} stu[100000];
int i;
int s1=0,s2=0,s3=0;
int x1=0,x2=0,x3=0;
for(i=0;i<n;i++)
{
scanf("%d %d %d\n",&stu[i].id,&stu[i].yu,&stu[i].shu);
}
int s,x;
for(i=0;i<n;i++)
{
s=stu[i].yu+stu[i].shu;
x=stu[i].id;
if(s>s1)
{s3=s2;x3=x2;s2=s1;x2=x1;s1=s;x1=x;}
else if(s==s1)
{s3=s2;x3=x2;s2=s;x2=x;}
else if(s<s1&&s>s2)
{s3=s2;x3=x2;s2=s;x2=x;}
else if(s==s2)
{s3=s;x3=x;}
else if(s<s2&&s>s3)
{s3=s;x3=x;}
}
printf("%d %d\n",x1,s1);
printf("%d %d\n",x2,s2);
printf("%d %d\n",x3,s3);
return 0;
} |
14 | 6834 | struct student
{
int num;
int chi;
int mat;
int sum;
}stu[100000];
void main()
{
int i,n,max=0,m,k;
scanf("%d",&n);
for(i=0;i<n;i++) {scanf("%d %d %d",&stu[i].num,&stu[i].chi,&stu[i].mat);stu[i].sum=stu[i].chi+stu[i].mat;}
for(k=0;k<3;k++)
{
for(i=0;i<n;i++) if(stu[i].sum>max) {max=stu[i].sum;m=i;}
printf("%d %d\n",stu[m].num,stu[m].sum);
stu[m].sum=0;
max=0;
}
}
|
14 | 6835 | struct student
{
int id;
int math;
int chinese;
int zongfen;
};
main()
{
int n,i=1,j;
int a[100001];
struct student stu[100001];
scanf("%d",&n);
for (i=1;i<=n;i++)
{
scanf("%d %d %d",&stu[i].id,&stu[i].math,&stu[i].chinese);
stu[i].zongfen=stu[i].math+stu[i].chinese;
if (i<4)
j=i;
else
j=4;
{
for(;j>1&&stu[i].zongfen>stu[a[j-1]].zongfen;j--)
a[j]=a[j-1];
}
a[j]=i;
}
for(i=1;i<=3;i++)
printf("%d %d\n",stu[a[i]].id,stu[a[i]].zongfen);
getchar();
getchar();
scanf("%d",&n);
return 0;
}
|
14 | 6836 | struct student
{
char xuehao[100];
int yuwen;
int shuxue;
int sum;
};
int main()
{
int n,i,j,l,m;
struct student stu[100000];
struct student temp;
scanf("%d",&n);
for (i=0;i<n;i++)
{
scanf("%s",stu[i].xuehao);
scanf("%d %d",&stu[i].yuwen,&stu[i].shuxue);
stu[i].sum=stu[i].yuwen+stu[i].shuxue;
}
for(j=1;j<4;j++)
{
for(m=0;m<n-j;m++)
{
if(stu[m].sum>=stu[m+1].sum)
{
temp=stu[m];
stu[m]=stu[m+1];
stu[m+1]=temp;
}
}
}
for(l=n-1;l>n-4;l--)
printf("%s %d\n",stu[l].xuehao,stu[l].sum);
return 0;
}
|
14 | 6837 | void main()
{
int i,n,m;
scanf("%d\n",&n);
int j,b[100000]={0},t,s;
struct student
{
int num;
int lang;
int math;
};
struct student a[100000];
for(i=0;i<n;i++) scanf("%d %d %d\n",&a[i].num,&a[i].lang,&a[i].math);
for(i=0;i<n;i++) b[i]=a[i].lang+a[i].math;
for(j=0;j<3;j++)
for(i=1;i<n-j;i++)
if(b[j]<b[j+i])
{t=b[j];b[j]=b[j+i];b[j+i]=t;}
for(j=0;j<3;j++)
for(i=0;i<n;i++)
{
m=a[i].lang+a[i].math;
if(m==b[j] && i!=s) {printf("%d %d\n",a[i].num,m);s=i;break;}
}
}
|
14 | 6838 | void main()
{
int i,j,n,k;
struct student
{
int num;
int score1;
int score2;
int t;
}stu[100000],m1,m2,m3;
scanf("%d\n",&n);
for(i=0;i<n;i++)
{
scanf("%d %d %d\n",&stu[i].num,&stu[i].score1,&stu[i].score2);
stu[i].t=stu[i].score1+stu[i].score2;
}
m1=stu[0];
m2=stu[0];
m3=stu[0];
for(i=0;i<n;i++)
{
if(stu[i].t>m1.t)
{
m3=m2;
m2=m1;
m1=stu[i];
}
else if(stu[i].t>m2.t&&stu[i].t<=m1.t)
{
m3=m2;
m2=stu[i];
}
else if(stu[i].t>m3.t&&stu[i].t<=m2.t)
{
m3=stu[i];
}
}
printf("%d %d\n%d %d\n%d %d",m1.num,m1.t,m2.num,m2.t,m3.num,m3.t);
}
|
14 | 6839 |
struct student
{
int num,cn,math,sum,rank;
struct student *next;
};
int n;
struct student * creat(void)
{
int i=1;
struct student *head;
struct student *p1,*p2;
p1=p2=(struct student *)malloc(LEN);
scanf("%d %d %d",&p1->num,&p1->cn,&p1->math);
head=p1;
do
{
p2=p1;
if(i==n)
break;
p1=(struct student *) malloc(LEN);
scanf("%d %d %d",&p1->num,&p1->cn,&p1->math);
p2->next=p1;
i++;
}while(1);
p2->next=0;
return(head);
}
void count(struct student *head)
{
int max=0;
struct student *p1;
n=1;
p1=head;
do
{
p1->sum=p1->cn+p1->math;
if(max<p1->sum)
max=p1->sum;
if(p1->next==0)
break;
p1=p1->next;
}while(1);
p1=head;
do
{
if(p1->sum==max)
{
p1->rank=n;
n++;
}
if(n>3)break;
if(p1->next==0)
{
p1=head;
max--;
}
else
p1=p1->next;
}while(1);
}
void print(struct student *head)
{
struct student *p1;
n=1;
p1=head;
do
{
if (p1->rank==n)
{
printf("%d %d\n",p1->num,p1->sum);
n++;
}
if(n>3)
break;
if(p1->next==0)
p1=head;
else p1=p1->next;
}while(1);
}
void main()
{
struct student *head;
scanf("%d",&n);
head=creat();
count(head);
print(head);
}
|
14 | 6840 | struct student { int id; char yw;char sx;int zf;int pm;};
int main()
{
struct student a[100000],b[2];
int n,i,j;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d%d%d",&a[i].id,&a[i].yw,&a[i].sx);
for(i=0;i<n;i++)
a[i].zf=a[i].yw+a[i].sx;
j=0;
for(i=0;i<n;i++)
if(a[i].zf>j)
{j=a[i].zf;b[0]=a[i];}
printf("%d %d\n",b[0].id,b[0].zf);
j=0;
for(i=0;i<n;i++)
if(a[i].zf>j&&a[i].id!=b[0].id)
{j=a[i].zf;b[1]=a[i];}
printf("%d %d\n",b[1].id,b[1].zf);
j=0;
for(i=0;i<n;i++)
if(a[i].zf>j&&a[i].id!=b[0].id&&a[i].id!=b[1].id)
{j=a[i].zf;b[2]=a[i];}
printf("%d %d\n",b[2].id,b[2].zf);
} |
14 | 6841 | /*
* statistics of scores.cpp
*
* Created on: 2011-12-11
* Author: Administrator
*/
struct stu
{
int Num;
int scoreC;
int scoreM;
int all;
};
struct stu stu[100005];
void fsort(int first,int last)
{
int chosen1,chosen2,p,q;
if(first>=last){return;}
chosen1=stu[first].all;
chosen2=stu[first].Num;
p=first;q=last;
while(p<q)
{
while((p<q)&&(stu[q].all>=chosen1)){q--;}
if(p<q){stu[p].all=stu[q].all;stu[p].Num=stu[q].Num;p++;}
while((p<q)&&(stu[p].all<chosen1)){p++;}
if(p<q){stu[q].all=stu[p].all;stu[q].Num=stu[p].Num;q--;}
}
stu[p].all=chosen1;stu[p].Num=chosen2;
fsort(first,p-1);
fsort(p+1,last);
}
int main()
{
int m,i;//????
cin>>m;
for(i=1;i<=m;i++)//????
{
cin>>stu[i].Num>>stu[i].scoreC>>stu[i].scoreM;
stu[i].all=stu[i].scoreC+stu[i].scoreM;
}
fsort(1,m);
cout<<stu[m].Num<<" "<<stu[m].all<<endl;//?????
cout<<stu[m-1].Num<<" "<<stu[m-1].all<<endl;
cout<<stu[m-2].Num<<" "<<stu[m-2].all<<endl;
return 0;
}
|
14 | 6842 | struct f{
int a;
int b;
int c;}st[100000],tp;
int main(){
int n,i,ii,j,d,a,b,c;
char cc;
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d%d%d",&st[i].a,&st[i].b,&st[i].c);
st[i].b+=st[i].c;
}
for(i=1;i<=3;i++){
for(j=i+1;j<=n;j++){
if(st[j].b>st[i].b){
tp=st[i];
st[i]=st[j];
st[j]=tp;}}}
for(i=1;i<=3;i++)
printf("%d %d\n",st[i].a,st[i].b);
}
|
14 | 6843 | struct Student
{
int num;
int chinese;
int math;
}sdu[99999];
int main()
{
int N,i,j,s,t,m;
scanf("%d",&N);
for(i=0;i<N;i++)
scanf("%d%d%d",&sdu[i].num,&sdu[i].chinese,&sdu[i].math);
for(j=0;j<3;j++){
for(i=0;i<N-j-1;i++)
if((sdu[i].chinese+sdu[i].math)>=(sdu[i+1].chinese+sdu[i+1].math)){
s=sdu[i].num;t=sdu[i].chinese;m=sdu[i].math;
sdu[i].num=sdu[i+1].num;sdu[i].chinese=sdu[i+1].chinese;sdu[i].math=sdu[i+1].math;
sdu[i+1].num=s;sdu[i+1].chinese=t;sdu[i+1].math=m;
}
}
for(i=0;i<3;i++)
printf("%d %d\n",sdu[N-1-i].num,sdu[N-1-i].chinese+sdu[N-1-i].math);
} |
14 | 6844 | struct stu
{
int id;
int eng;
int math;
int sum;
struct stu *next;
}*head,*p1,*p2;
struct stu *order(int n)
{
int i,j,t;
p1=head;
for(i=0;i<3;i++)
{
p2=p1->next;
for(j=i+1;j<n;j++)
{ if(p1->sum<p2->sum)
{
t=p1->id;p1->id=p2->id;p2->id=t;
t=p1->sum;p1->sum=p2->sum;p2->sum=t;
}
p2=p2->next;}
p1=p1->next;
}
return head;
}
void main()
{
int n,i;
scanf("%d",&n);
p1=head=(struct stu *)malloc(sizeof(struct stu));
for(i=0;i<n;i++)
{
scanf("%d %d %d",&p1->id,&p1->eng,&p1->math);
p1->sum=p1->eng+p1->math;
p2=p1;
p1=(struct stu *)malloc(sizeof(struct stu));
p2->next=p1;
}
p2->next=NULL;
p1=order(n);
for(i=0;i<3;i++)
{
printf("%d %d\n",p1->id,p1->sum);
p1=p1->next;
}
} |
14 | 6845 | struct student
{
int num;
int chinese;
int math;
int sum;
}work[100001];
void qsort(int left,int right)
{
if (left>=right) return;
int pindex=left,rindex=right;
work[0]=work[left];
while (pindex<rindex)
{
while ((pindex<rindex)&&(work[rindex].sum>=work[0].sum))
rindex--;
if (pindex<rindex){work[pindex]=work[rindex];pindex++;}
while ((pindex<rindex)&&(work[pindex].sum<work[0].sum))
pindex++;
if (pindex<rindex){work[rindex]=work[pindex];rindex--;}
}
work[pindex]=work[0];
qsort(left,pindex-1);
qsort(pindex+1,right);
}
int main()
{
int n,i;
cin>>n;
for (i=1;i<=n;i++)
{
cin>>work[i].num>>work[i].chinese>>work[i].math;
work[i].sum=work[i].chinese+work[i].math;
}
qsort(1,n);
for (i=0;i<=2;i++)
cout<<work[n-i].num<<" "<<work[n-i].sum<<endl;
return 0;
} |
14 | 6846 |
int main()
{
struct student
{
int num, ch, ma, grade;
}sum[100000], h, m, t;
int i, n;
scanf("%d", &n);
for(i=0;i<n;i++)
{
scanf("%d%d%d", &sum[i].num, &sum[i].ch, &sum[i].ma);
sum[i].grade=sum[i].ch+sum[i].ma;
}
h.grade=m.grade=t.grade=0;
for(i=0;i<n;i++)
{
if(sum[i].grade>h.grade)
{
t=m;
m=h;
h=sum[i];
}
else if(sum[i].grade>m.grade)
{
t=m;
m=sum[i];
}
else if(sum[i].grade>t.grade)
t=sum[i];
}
printf("%d %d\n%d %d\n%d %d\n", h.num, h.grade, m.num, m.grade, t.num, t.grade);
return 0;
}
|
14 | 6847 | struct student
{
int num;
double chi;
double math;
double total;
};
int main()
{
struct student stu[100000];
struct student temp;
int n,i,j,k;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%lf%lf",&stu[i].num,&stu[i].chi,&stu[i].math);
stu[i].total=stu[i].chi+stu[i].math;
}
for(i=0;i<3;i++)
{
k=i;
for(j=i;j<n;j++)
{
if(stu[k].total<stu[j].total)
{
k=j;
}
}
if(k!=i)
{
temp=stu[i];
stu[i]=stu[k];
stu[k]=temp;
}
}
for(i=0;i<3;i++)
{
printf("%d %.0lf\n",stu[i].num,stu[i].total);
}
return 0;
}
|
14 | 6848 | int main()
{
int num[3],sum[3];
int i,j,k,t,n,m;
num[0]=num[1]=num[2]=sum[0]=sum[1]=sum[2]=-10000000;
scanf("%d",&n);
for(m=0;m<n;m++)
{
scanf("%d%d%d",&i,&j,&k);
j+=k;
if(sum[2]<j)
{
sum[2]=j;
num[2]=i;
if(sum[2]>sum[1])
{
t=sum[2];
sum[2]=sum[1];
sum[1]=t;
t=num[2];
num[2]=num[1];
num[1]=t;
if(sum[1]>sum[0])
{
t=sum[0];
sum[0]=sum[1];
sum[1]=t;
t=num[0];
num[0]=num[1];
num[1]=t;
}
}
}
}
for(i=0;i<3;i++)
printf("%d %d\n",num[i],sum[i]);
return 0;
} |
14 | 6849 | struct student
{
int id;
int c;
int m;
int t;
} a[SIZE];
int cmp(const void*p1,const void*p2)
{
struct student*p3=(struct student*)p1;
struct student*p4=(struct student*)p2;
return -p3->t+p4->t;
}
int main(void)
{
int n, i;
scanf("%d",&n);
for(i=0;i<n;i++)
{scanf("%d%d%d",&a[i].id,&a[i].c,&a[i].m);a[i].t=a[i].m+a[i].c;}
qsort(a,n,sizeof(a[0]),cmp);
for(i=0;i<3;i++)
printf("%d %d\n", a[i].id, a[i].c+a[i].m);
return 0;
}
|
14 | 6850 | int main ( ) {
int N , i ;
cin >> N ;
int Max1 = 0 , Max2 = 0 , Max3 = 0 , Nb[4] ;
struct student {
int Number ;
int Chinese ;
int Math ;
int Total ;
}people[111111];
for ( i = 1 ; i <= N ; i ++ ) {
cin >> people[i].Number >> people[i].Chinese >> people[i].Math ;
people[i].Total = people[i].Chinese + people[i].Math ;
}
for ( i = 1 ; i <= N ; i ++ ) {
if ( Max1 < people[i].Total ){
Nb[1] = i ;
Max1 = people[i].Total ;
}
}
for ( i = 1 ; i <= N ; i ++ ) {
if ( ( Max2 < people[i].Total ) && ( i != Nb[1] ) ){
Nb[2] = i ;
Max2 = people[i].Total ;
}
}
for ( i = 1 ; i <= N ; i ++ ) {
if ( ( Max3 < people[i].Total ) && ( i != Nb[1] ) && ( i != Nb[2] ) ){
Nb[3] = i ;
Max3 = people[i].Total ;
}
}
for ( i = 1 ; i <= 3 ; i ++ ) {
cout << people[Nb[i]].Number << " " << people[Nb[i]].Total ;
if ( i < 3 )
cout << endl ;
}
return 0 ;
} |
14 | 6851 |
int main(int argc, char* argv[])
{
long n;
long num[99999],math[99999],china[99999],z[99999],i;
long num1=2,num2=1,num3=0,m1=0,m2=0,m3=0;
scanf("%ld",&n);
for(i=1;i<=n;i++)
{
scanf("%ld",&num[i]);
scanf("%ld",&math[i]);
scanf("%ld",&china[i]);
z[i]=math[i]+china[i];
if(z[i]>num3)
{
num1=num2;
m1=m2;
num2=num3;
m2=m3;
num3=z[i];
m3=i;
}
else if(z[i]>num2)
{
num1=num2;
m1=m2;
num2=z[i];
m2=i;
}
else if(z[i]>num1)
{
num1=z[i];
m1=i;
}
}
printf("%ld %ld\n",m3,num3);
printf("%ld %ld\n",m2,num2);
printf("%ld %ld\n",m1,num1);
return 0;
} |
14 | 6852 | int main()
{
int n,i,num[100000],j,grade1[100000],grade2[100000],grade[100000],t1,t2;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d %d %d",&num[i],&grade1[i],&grade2[i]);
grade[i]=grade1[i]+grade2[i];
}
for(j=1;j<4;j++)
{
for(i=0;i<n-j;i++)
{
if(grade[i]>=grade[i+1])
{
t1=grade[i];
grade[i]=grade[i+1];
grade[i+1]=t1;
t2=num[i];
num[i]=num[i+1];
num[i+1]=t2;
}
}
}
printf("%d %d\n%d %d\n%d %d",num[n-1],grade[n-1],num[n-2],grade[n-2],num[n-3],grade[n-3]);
} |
14 | 6853 |
struct stu
{
int id;
int ch;
int mt;
int total;
};
struct stu stu_1[100000];
struct stu top1={0,0,0,0},top2={0,0,0,0},top3={0,0,0,0};
int main()
{ int n,i;
struct stu tem;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d %d",&(stu_1[i].id),&(stu_1[i].ch),&(stu_1[i].mt));
stu_1[i].total=stu_1[i].ch+stu_1[i].mt;
if(stu_1[i].total>top1.total){
top3=top2;top2=top1;top1=stu_1[i];
}
else if(stu_1[i].total>top2.total){
top3=top2;top2=stu_1[i];
}
else if(stu_1[i].total>top3.total){
top3=stu_1[i];
}
else;
}
printf("%d %d\n",top1.id,top1.total);
if((top2.id)!=0)
printf("%d %d\n",top2.id,top2.total);
if((top3.id)!=0)
printf("%d %d\n",top3.id,top3.total);
return 0;
} |
14 | 6854 | struct stu
{
int id;
int c;
int m;
int t;
};
int main()
{
int n,i,j,K;
struct stu a[4]={0};
struct stu b[4]={0};
struct stu temp={0};
scanf("%d",&n);
for(i=0;i<=(n-1);i++)
{
if(i<=2)
{scanf("%d%d%d",&a[i].id,&a[i].c,&a[i].m);
a[i].t=a[i].c+a[i].m;
b[i]=a[i];}
else
{
scanf("%d%d%d",&a[3].id,&a[3].c,&a[3].m);
a[3].t=a[3].c+a[3].m;
b[3]=a[3];
//a[3]="\0";
for(K=0;K<=3;K++)
{
for(j=0;j<=3;j++)
{
if(b[j].t<b[j+1].t)
{ temp=b[j];
b[j]=b[j+1];
b[j+1]=temp;
}
}
}
}
}
for(i=0;i<=2;i++)
{
printf("%d %d\n",b[i].id,b[i].t);
}
} |
14 | 6855 |
struct student{
int num;
int chin;
int math;
int sum;
}tem_stu;
int main()
{
int n,i;
scanf("%d",&n);
struct student *stu;
stu=(struct student*)malloc(n*sizeof(struct student));
for(i=0;i<n;i++){
scanf("%d%d%d",&stu[i].num,&stu[i].chin,&stu[i].math);
stu[i].sum=stu[i].chin+stu[i].math;
}
int j;
for(j=1;j<4;j++){
for(i=0;i<n-j;i++){
if(stu[i].sum>=stu[i+1].sum){
tem_stu=stu[i+1];
stu[i+1]=stu[i];
stu[i]=tem_stu;
}
}
}
printf("%d %d\n",stu[n-1].num,stu[n-1].sum);
printf("%d %d\n",stu[n-2].num,stu[n-2].sum);
printf("%d %d\n",stu[n-3].num,stu[n-3].sum);
free(stu);
return 0;
}
|
14 | 6856 | struct student
{
int num;
int chi;
int math;
struct student *next;
};
struct student *creat(int n)
{
struct student *head,*p1,*p2;
int i;
p1=p2=(struct student *)malloc(LEN);
scanf("%d %d %d",&p1->num,&p1->chi,&p1->math);
head=p1;
for(i=2;i<=n;i++)
{
p1=(struct student *)malloc(LEN);
scanf("%d %d %d",&p1->num,&p1->chi,&p1->math);
p2->next=p1;
p2=p1;
}
p2->next=NULL;
return head;
}
void main()
{
struct student *head,*p,*p1,*p2,*p3;
int n,m1,m2,m3,k;
scanf("%d",&n);
head=creat(n);
p=head;
m1=m2=m3=0;
if(head!=NULL)
{
do
{
k=p->chi+p->math;
if(k>m1)
{ m1=k;p1=p;}
p=p->next;
}
while(p!=NULL);
p=head;
do
{
k=p->chi+p->math;
if((k>m2)&&(p!=p1))
{ m2=k;p2=p;}
p=p->next;
}
while(p!=NULL);
p=head;
do
{
k=p->chi+p->math;
if((k>m3)&&(p!=p1)&&(p!=p2))
{ m3=k;p3=p;}
p=p->next;
}
while(p!=NULL);
}
printf("%d %d\n%d %d\n%d %d\n",p1->num,m1,p2->num,m2,p3->num,m3);
} |
14 | 6857 | void main()
{
struct stu
{int num;
int chi;
int mat;
}stu[100000];
int n,i,max1,max2,max3,maxn1,maxn2,maxn3;
int sum[100000];
scanf("%d",&n);
for(i=0;i<n;i++)
{scanf("%d",&stu[i].num);
scanf("%d",&stu[i].chi);
scanf("%d",&stu[i].mat);
sum[i]=stu[i].chi+stu[i].mat;
}
max1=sum[0];
maxn1=stu[0].num;
for(i=1;i<n;i++)
{
if(sum[i]>max1)
{
max1=sum[i];
maxn1=stu[i].num;
}
}
printf("%d %d\n",maxn1,max1) ;
max2=sum[0];
maxn2=stu[0].num;
for(i=1;i<n;i++)
{
if(sum[i]>max2&&i!=maxn1-1)
{
max2=sum[i];
maxn2=stu[i].num;
}
}
printf("%d %d\n",maxn2,max2) ;
max3=sum[0];
maxn3=stu[0].num;
for(i=1;i<n;i++)
{
if(sum[i]>max3&&i!=maxn1-1&&i!=maxn2-1)
{
max3=sum[i];
maxn3=stu[i].num;
}
}
printf("%d %d\n",maxn3,max3) ;
} |
14 | 6858 | int main()
{
int n,i,m;
int a,b,c;
int j,k,v;
int sum[100000];
int max1=0,max2=0,max3=0;
int A[100000][1];
scanf ("%d",&n);
for (i=1;i<=n;i++)
{
scanf ("%d %d %d",&m,&A[i][0],&A[i][1]);
sum[i]=A[i][0]+A[i][1];
}
for (j=1;j<=n;j++)
{
if (sum[j]>max1)
{max1=sum[j];
a=j;}
}
for (k=1;k<=n;k++)
{
if (sum[k]>max2&&k!=a)
{max2=sum[k];
b=k;}
}
for (v=1;v<=n;v++)
{
if (sum[v]<max2)
{
if (sum[v]>max3)
{max3=sum[v];
c=v;}
}
}
printf ("%d %d\n",a,max1);
printf ("%d %d\n",b,max2);
printf ("%d %d",c,max3);
return 0;
}
|
14 | 6859 | struct student
{
long num;
int chi;
int math;
int sum;
struct student *next;
};
long n;
void main()
{
struct student *creat();
struct student *head,*p,*q1,*q2,*q3;
int a;
scanf("%ld",&n);
head=creat();
p=head;
a=0;
while(p!=NULL)
{
if(p->sum>a)
{
a=p->sum;
q1=p;
}
p=p->next;
}
p=head;
a=0;
while(p!=NULL)
{
if(p->sum>a&&p!=q1)
{
a=p->sum;
q2=p;
}
p=p->next;
}
p=head;
a=0;
while(p!=NULL)
{
if(p->sum>a&&p!=q1&&p!=q2)
{
a=p->sum;
q3=p;
}
p=p->next;
}
printf("%d %d\n",q1->num,q1->sum);
printf("%d %d\n",q2->num,q2->sum);
printf("%d %d\n",q3->num,q3->sum);
}
struct student *creat()
{
struct student *head,*p1,*p2;
int i;
head=NULL;
p1=p2=(struct student *)malloc(LEN);
for(i=0;i<=n-1;i++)
{
scanf("%ld%d%d",&p1->num,&p1->chi,&p1->math);
p1->sum=p1->chi+p1->math;
if(i==0) head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(LEN);
}
p2->next=NULL;
return(head);
} |
14 | 6860 | int sum[1000000];
struct student{
int id;
int Gra[2];
}stu[1000000];
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>stu[i].id>>stu[i].Gra[0]>>stu[i].Gra[1];
sum[i]=stu[i].Gra[0]+stu[i].Gra[1];
}
int max=0,imax=0;
for(int i=0;i<3;i++)
{ max=0;
for(int j=0;j<n;j++)
if(max<sum[j]) {max=sum[j];imax=j;}
cout<<stu[imax].id<<" "<<sum[imax]<<endl;
sum[imax]=0;
}
return 0;
}
|
14 | 6861 | struct student
{
int id;
int c;
int m;
int s;
struct student *next;
};
struct student *creat(void)
{
struct student *head,*p1,*p2;
int n,i;
p1=p2=(struct student*)malloc(LEN);
scanf("%d",&n);
head=NULL;
for(i=0;i<n;i++)
{
scanf("%d%d%d",&p1->id,&p1->c,&p1->m);
p1->s=p1->c+p1->m;
if(i==0)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(LEN);
}
p2->next=NULL;
return (head);
}
void exchange(struct student *x,struct student *y)
{
int t;
t=x->id;x->id=y->id;y->id=t;
t=x->c;x->c=y->c;y->c=t;
t=x->m;x->m=y->m;y->m=t;
t=x->s;x->s=y->s;y->s=t;
}
void main()
{
struct student *p,*q,*head;
int temp,i;
head=p=creat();
for(p=head,i=0;p->next!=NULL,i<3;p=p->next,i++)
{
temp=p->s;
for(q=p->next;q!=NULL;q=q->next)
{
if(p->s<q->s)temp=q->s;
if(p->s!=temp)exchange(p,q);
}
}
for(p=head,i=0;i<3;p=p->next,i++)
printf("%d %d\n",p->id,p->s);
}
|
14 | 6862 | int n,max1,xue1,max2,xue2,max3,xue3;
struct chengji
{
int xh;
int yw;
int sx;
int zf;
struct chengji *next;
};
void create()
{
struct chengji *head;
struct chengji *p1;
int i=0;
while(i<n)
{ i++;
if (i==1) head=p1;
p1=(struct chengji *)malloc(len);
scanf("%d %d %d",&p1->xh,&p1->yw,&p1->sx);
p1->zf=p1->yw+p1->sx;
if ((p1->zf)>max1)
{
xue3=xue2;
max3=max2;
xue2=xue1;
max2=max1;
xue1=p1->xh;
max1=p1->zf;
}
else
{if ((p1->zf)>max2&&(p1->zf)<=max1)
{
xue3=xue2;
max3=max2;
xue2=p1->xh;
max2=p1->zf;
}
else {if ((p1->zf)>max3&&(p1->zf)<=max2)
{
xue3=p1->xh;
max3=p1->zf;
}}}
p1=p1->next;
}
}
void main()
{
scanf("%d",&n);
max1=0,max2=0,max3=0;
create();
printf("%d %d\n",xue1,max1);
printf("%d %d\n",xue2,max2);
printf("%d %d",xue3,max3);
} |
14 | 6863 |
struct st
{int I;
int c;
int m;
}
st[100000];
int main()
{
int n,i,j,k=0,a,b;
scanf("%d",&n);
for (i=0;i<n;i++)
{
scanf("%d %d %d",&st[i].I,&st[i].c,&st[i].m);
}
for (i=0;i<3;i++)
{
for(j=0;j<n;j++)
{
if (k<st[j].c+st[j].m)
{
k=st[j].c+st[j].m;
a=st[j].I;
b=j;
}
}
st[b].c=0;
st[b].m=0;
printf("%d %d",a,k);
if (i<2)
printf("\n");
k=0;
}
}
|
14 | 6864 | int stu [100000];
int main(int argc, char* argv[])
{
int n,i,j,y,t,m;
struct s{
int a;
int b;
int c;
}stu[100000];
scanf ("%d",&n);
for (i=0;i<n;i++)
{
scanf ("%d%d%d",&stu[i].a,&stu[i].b,&stu[i].c);
}
for (i=0;i<3;i++)
{
for (j=i+1;j<n;j++)
{
if ((stu[j].b+stu[j].c)>(stu[i].b+stu[i].c))
{
y=stu[i].b;t=stu[i].c;m=stu[i].a;
stu[i].b=stu[j].b;
stu[j].b=y;
stu[i].c=stu[j].c;
stu[j].c=t;
stu[i].a=stu[j].a;
stu[j].a=m;
}
}
}
for (i=0;i<3;i++)
{
printf ("%d %d\n",stu[i].a,(stu[i].b+stu[i].c));
}
return 0;
}
|
14 | 6865 | int s[100001];
int main()
{
int n,i,j;
scanf("%d",&n);
struct{
int id,chin,math,su;
}s[100001];
for(i=0;i<n;i++)
{
scanf("%d%d%d",&s[i].id,&s[i].chin,&s[i].math);
s[i].su=s[i].chin+s[i].math;
}
for(i=0;i<3;i++)
{
for(j=i+1;j<n;j++)
{
if(s[i].su<s[j].su)
{
s[100000]=s[i];
s[i]=s[j];
s[j]=s[100000];
}
}
}
printf("%d %d\n%d %d\n%d %d",s[0].id,s[0].su,s[1].id,s[1].su,s[2].id,s[2].su);
return 0;
} |
14 | 6866 |
int main()
{
long n,i;
int high[4]={0};
long higher[4];
struct student
{
long num;
int yuwen;
int shuxue;
int total;
}stu[100000];
scanf("%d",&n);
for (i=1;i<=n;i++)
{
scanf("%d %d %d",&stu[i].num,&stu[i].yuwen,&stu[i].shuxue);
stu[i].total=stu[i].yuwen+stu[i].shuxue;
if (stu[i].total>high[1])
{
high[1]=stu[i].total;
higher[1]=i;
}
}
for (i=1;i<=n;i++)
if (stu[i].total<=high[1]&&stu[i].total>high[2]&&i!=higher[1])
{
high[2]=stu[i].total;
higher[2]=i;
}
for (i=1;i<=n;i++)
if (stu[i].total<=high[2]&&stu[i].total>high[3]&&i!=higher[1]&&i!=higher[2])
{
high[3]=stu[i].total;
higher[3]=i;
}
for (i=1;i<4;i++)
printf("%d %d\n",higher[i],high[i]);
} |
14 | 6867 | int main()
{
long int n,a[100000][2];
int i,j,t,s;
struct Student
{int num;
int yu;
int shu;
};
scanf("%d",&n);
for(i=0;i<n;i++)
{
struct Student studenti;
scanf("%d%d%d",&studenti.num,&studenti.yu,&studenti.shu);
a[i][0]=studenti.num;
a[i][1]=studenti.yu+studenti.shu;
}
for(i=0;i<3;i++)
{ for(j=0;j<n-1-i;j++)
{if(a[j][1]>=a[j+1][1])
{t=a[j][1];a[j][1]=a[j+1][1];a[j+1][1]=t;
s=a[j][0];a[j][0]=a[j+1][0];a[j+1][0]=s;
}
}
}
for(i=1;i<=3;i++)
printf("%d %d\n",a[n-i][0],a[n-i][1]);
return 0;
}
|
14 | 6868 | int main ()
{
struct student
{
int num;
int ch;
int ma;
int sum;
};
struct student *p;
int n, i, j, t1, t2, a1=0, a2=0, a3=0, k1, k2, k3;
scanf ("%d", &n);
p=(struct student *)malloc (n*sizeof (struct student));
for (i=0; i<n; i++)
{ scanf ("%d%d%d", &p[i].num, &p[i].ch, &p[i].ma);
p[i].sum= p[i].ch+p[i].ma; }
/*for (j=0; j<n-1; j++)
for (i=0; i<n-1-j; i++)
if (p[i].sum<p[i+1].sum)
{ t1=p[i].num; p[i].num=p[i+1].num; p[i+1].num=t1;
t2=p[i].sum; p[i].sum=p[i+1].sum; p[i+1].sum=t2; }*/
for (i=0; i<n; i++)
if (p[i].sum>a1) { k1=i; a1=p[i].sum; }
for (i=0; i<n; i++)
if (p[i].sum<=a1 && p[i].sum>a2 && i!=k1) { k2=i; a2=p[i].sum; }
for (i=0; i<n; i++)
if (p[i].sum<=a2 && p[i].sum>a3 && i!=k1 && i!=k2) { k3=i; a3=p[i].sum; }
printf ("%d %d\n%d %d\n%d %d\n", p[k1].num, p[k1].sum, p[k2].num, p[k2].sum, p[k3].num, p[k3].sum);
/*for (i=0; i<3; i++)
printf ("%d %d\n", p[i].num, p[i].sum);*/
return 0;
} |
14 | 6869 | int main()
{int n,sum[100000],a,b,c;
struct xues{int a,b,c;} s[100000];
scanf ("%d",&n);
int i;
for(i=0;i<n;i++){
scanf("%d%d%d",&s[i].a,&s[i].b,&s[i].c);
sum[i]=s[i].b+s[i].c;
}
int fir=0,sec=0,thi=0;
for(i=0;i<n;i++){
if(fir<sum[i]){
thi=sec;
sec=fir;
fir=sum[i];
c=b;
b=a;
a=s[i].a;
}
else if(sec<sum[i]){
thi=sec;
sec=sum[i];
fir=fir;
a=a;
c=b;
b=s[i].a;
}
else if(thi<sum[i]){
fir=fir;
sec=sec;
thi=sum[i];
a=a;
b=b;
c=s[i].a;
}
}
printf("%d %d\n%d %d\n%d %d",a,fir,b,sec,c,thi);
return 0;
}
|
14 | 6870 | struct student
{ int ID;
int ch;
int ma;
};
void main()
{ struct student re[N];
int n;
int i=0,j=0,rec;
int total[N];
scanf("%d",&n);
for(i=0;i<n;i++)
{ scanf("%d%d%d",&re[i].ID,&re[i].ch,&re[i].ma);
total[i]=re[i].ch+re[i].ma;
}
int max=total[0];
for(i=0;i<n;i++)
{ if(max<total[i])
{ max=total[i];
rec=i;
}
if(i==n-1)
{ printf("%d %d\n",re[rec].ID,total[rec]);
total[rec]=0;
i=0;
max=total[0];
j++;
}
if(j==3)
break;
}
}
|
14 | 6871 |
typedef struct {
int d;
int score;
} student;
int main()
{
int n, i, temp1, temp2;
student a[100002];
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d%d%d", &a[i].d, &temp1, &temp2);
a[i].score = temp1 + temp2;
}
student max1, max2, max3;
max1.d = max2.d = max3.d = -1;
max1.score = max2.score = max3.score = 0;
for (i = 0; i < n; i++) {
if (a[i].score > max1.score) {
max3 = max2;
max2 = max1;
max1 = a[i];
}
else if (a[i].score > max2.score) {
max3 = max2;
max2 = a[i];
}
else if (a[i].score > max3.score) {
max3 = a[i];
}
}
printf("%d %d\n", max1.d, max1.score);
if (max2.d != -1)
printf("%d %d\n", max2.d, max2.score);
if (max3.d != -1)
printf("%d %d\n", max3.d, max3.score);
return 0;
}
|
14 | 6872 |
struct ace
{
char id[10];
int a;
int b;
}o[3],r;
void main()
{
int n,i,s[3],m,j,v;
char z[10];
scanf("%d",&n);
scanf("%s %d %d",o[0].id,&o[0].a,&o[0].b);
scanf("%s %d %d",o[1].id,&o[1].a,&o[1].b);
scanf("%s %d %d",o[2].id,&o[2].a,&o[2].b);
s[0]=o[0].a+o[0].b;
s[1]=o[1].a+o[1].b;
s[2]=o[2].a+o[2].b;
for(i=0;i<2;i++)
{
for(j=i+1;j<3;j++)
{
if(s[i]<s[j])
{
strcpy(z,o[i].id);
strcpy(o[i].id,o[j].id);
strcpy(o[j].id,z);
v=s[i];
s[i]=s[j];
s[j]=v;
}
}
}
for(i=0;i<n-3;i++)
{
scanf("%s %d %d",r.id,&r.a,&r.b);
m=r.a+r.b;
if(m>s[0] )
{o[2]=o[1];s[2]=s[1];o[1]=o[0];s[1]=s[0];o[0]=r;s[0]=m;}
else if(m<=s[0] && m>s[1])
{o[2]=o[1];s[2]=s[1];o[1]=r;s[1]=m;}
else if(m<=s[1] && m>s[2])
{o[2]=r;s[2]=m;}
}
printf("%s %d\n",o[0].id,s[0]);
printf("%s %d\n",o[1].id,s[1]);
printf("%s %d\n",o[2].id,s[2]);
}
|
14 | 6873 | struct statistics
{int num; int chinese; int math; int sum;}
form[100000],temp;
int main()
{ int n;
scanf("%d",&n);
int i,j;
for(i=0;i<n;i++)
{scanf("%d %d %d",&form[i].num,&form[i].chinese,&form[i].math);
form[i].sum=form[i].chinese+form[i].math;}for(i=0;
i<3&&i<n-1;i++){int k=i;for(j=i+1;j<n;j++){if(form[j].sum>form[k].sum){k=j;}
}
if (k!=i){temp=form[i];
form[i]=form[k];
form[k]=temp; }}
for(i=0;i
<3&&i<n;i++)printf("%d %d\n",form[i].num,form[i].sum);
return 0;} |
14 | 6874 | struct stu
{
long xh;
int yw;
int sx;
int zh;
struct stu *next;
};
struct stu *scan()
{
long n;
long num=0;
struct stu *head,*p1,*p2;
p1=p2=(struct stu *)malloc(sizeof (struct stu));
scanf("%ld",&n);
// head=0;
head=p1;
while(num<n)
{
scanf("%ld",&p1->xh);
scanf("%d",&p1->yw);
scanf("%d",&p1->sx);
p1->zh=p1->yw+p1->sx;
p2=p1;
p1=(struct stu *)malloc(sizeof (struct stu));
p2->next=p1;
p1->next=0;
num++;
}
return(head);
}
struct stu *del(struct stu *head,int max)
{
struct stu *p1,*p2;
p1=head;
while(max!=p1->zh&&p1->next!=0)
{
p2=p1;
p1=p1->next;
}
if(max==p1->zh)
{
if(p1==head)
{
head=p1->next;
}
else
{
p2->next=p1->next;
}
}
return (head);
}
void print(struct stu *head)
{
struct stu *p,*p1,*p2,*p3,*w;
int max=0,num=0;
while(num<3)
{
for(p=head;p!=0;p=p->next)
{
if(p->zh>max)
{
max=p->zh;
w=p;
}
}
num++;
if(num==1)
{
p1=w;
head=del(head,max);
max=0;
}
if(num==2)
{
p2=w;
head=del(head,max);
max=0;
}
if(num==3)
{
p3=w;
}
}
printf("%ld %d\n%ld %d\n%ld %d\n",p1->xh,p1->zh,p2->xh,p2->zh,p3->xh,p3->zh);
}
void main()
{
struct stu *head;
head=scan();
print(head);
} |
14 | 6875 | /*
* xue sheng cheng ji tong ji.cpp
*
* Created on: 2010-12-26
* Author: taoshibo
*/
int main() {
int n = 0, i = 0, j = 0;
cin >> n;
struct student {//??????????????
int stuid;
int chin;
int math;
} stu[n], t;
for (i = 0; i < n; i++) {//???? ???????
cin >> stu[i].stuid >> stu[i].chin >> stu[i].math;
}
for (i = 0; i < 3; i++)//?????
for (j = 0; j < n - 1; j++)
if ((stu[j].chin + stu[j].math) >= (stu[j + 1].chin
+ stu[j + 1].math)) {
t = stu[j];
stu[j] = stu[j + 1];
stu[j + 1] = t;
}
for (i = n-1; i > n-4; i--)//?????
cout << stu[i].stuid << " " << stu[i].chin + stu[i].math << endl;
return 0;
}
|
14 | 6876 |
int main()
{
int id,chinese,math,total;
int n,i,a=0,b=0,c=0,x=0,y=0,z=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d%d%d",&id,&chinese,&math);
total=chinese+math;
if(total>a)
{
c=b;
z=y;
b=a;
y=x;
a=total;
x=id;
}
else if(total<=a&&total>b)
{
c=b;
z=y;
b=total;
y=id;
}
else if(total<=b&&total>c)
{
c=total;
z=id;
}
}
printf("%d %d\n",x,a);
printf("%d %d\n",y,b);
printf("%d %d\n",z,c);
return 0;
} |
14 | 6877 | struct student
{
int n;
int a;
int b;
int aver;
}stu[100000];
void main()
{
int m,i,j,f,t;
scanf("%d",&m);
for(i=0;i<m;i++)
{
scanf("%d%d%d",&stu[i].n,&stu[i].a,&stu[i].b);
}
for(i=0;i<m;i++)
{
stu[i].aver=stu[i].a+stu[i].b;
}
for(i=0;i<3;i++)
for(j=m-1-i;j>=0;j--)
{
if(stu[j].aver<stu[j+1].aver)
{
f=stu[j].aver;
stu[j].aver=stu[j+1].aver;
stu[j+1].aver=f;
t=stu[j].n;
stu[j].n=stu[j+1].n;
stu[j+1].n=t;
}
}
for(i=0;i<3;i++)
{
printf("%d %d\n",stu[i].n,stu[i].aver);
}
}
|
14 | 6878 | void main()
{
struct student
{
int num;
int a;
int b;
}stu[100000];
int n,i,sum=0,max1=0,max2=0,max3=0,t=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d %d %d",&stu[i].num,&stu[i].a,&stu[i].b);
sum=stu[i].a+stu[i].b;
if (sum>max1) {max3=max2;max2=max1;max1=sum;}
else if ((sum<max1)&&(sum>max2)){max3=max2;max2=sum;}
else if ((sum<max2)&&(sum>max3)){max3=sum;}
}
for(i=0;i<n;i++)
{
sum=stu[i].a+stu[i].b;
if (sum==max1) {printf("%d %d\n",stu[i].num,max1);t++;}
}
for(i=0;i<n;i++)
{
sum=stu[i].a+stu[i].b;
if ((sum==max2)&&(t<3)) {printf("%d %d\n",stu[i].num,max2);t++;}
}
for(i=0;i<n;i++)
{
sum=stu[i].a+stu[i].b;
if ((sum==max3)&&(t<3)) {printf("%d %d\n",stu[i].num,max3);t++;}
}
} |
14 | 6879 | struct student
{
char num[30];
float chi;
float mat;
float tot;
struct student *next;
};
struct student * creat(struct student *head,struct student *stud)
{
struct student *p0,*p1,*p2;
p1=head;
p0=stud;
if(head==NULL)
{head=p0;p0->next=NULL;}
else
{while((p0->tot<=p1->tot)&&(p1->next!=NULL))
{p2=p1;p1=p1->next;}
if(p0->tot>=p1->tot)
{if(head==p1) head=p0;
else p2->next=p0;
p0->next=p1;}
else
{p1->next=p0;p0->next=NULL;}
}
return(head);
}
struct student * compare(struct student *head,struct student *stud)
{
struct student *p0,*p1,*p2;
int i;
p1=head;
p0=stud;
while((p0->tot<=p1->tot)&&(p1->next!=NULL))
{p2=p1;p1=p1->next;}
if((p0->tot>p1->tot)||((p0->tot=p1->tot)&&(p1->next!=NULL)))
{
if(head==p1) head=p0;
else p2->next=p0;
p0->next=p1;
p1=head;
for(i=0;i<2;i++)
{p1=p1->next;}
p1->next=NULL;
}
return(head);
}
void print(struct student * head)
{
struct student *p;
int i;
p=head;
for(i=0;i<3;i++)
{
printf("%s %g\n",p->num,p->tot);
p=p->next;
}
}
void main()
{
struct student *head;
struct student *stu;
int n,i;
head=NULL;
scanf("%d",&n);
for(i=0;i<3;i++)
{ stu=(struct student *)malloc(LEN);
scanf("%s %f %f",&stu->num,&stu->chi,&stu->mat);
stu->tot=stu->chi+stu->mat;
head=creat(head,stu);
}
for(i=3;i<n;i++)
{
stu=(struct student *)malloc(LEN);
scanf("%s %f %f",&stu->num,&stu->chi,&stu->mat);
stu->tot=stu->chi+stu->mat;
head=compare(head,stu);
}
print(head);
}
|
14 | 6880 | int main()
{
struct student
{
int ID;
int yuwen;
int shuxue;
int zongfen;
};
struct student student[100000];
int n,i,max,maxID;
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d %d %d",&student[i].ID,&student[i].yuwen,&student[i].shuxue);
for(i=1;i<=n;i++)
student[i].zongfen=student[i].yuwen+student[i].shuxue;
for(int j=1;j<=3;j++)
{
maxID=1;
max=student[1].zongfen;
for(i=2;i<=n;i++)
if(student[i].zongfen>max)
{
maxID=student[i].ID;
max=student[i].zongfen;
}
printf("%d %d\n",maxID,max);
student[maxID].zongfen=0;
}
} |
14 | 6881 | /*
* ????????.cpp
*
* Created on: 2010-12-24
* Author: wangwei
*/
struct student
{
int id;
int chinese;
int math;
int together;
}stu[100000],t;
int main()
{
int n,i,j;
cin>>n;
for(i=0;i<n;i++)
{
cin>>stu[i].id>>stu[i].chinese>>stu[i].math;
stu[i].together=stu[i].chinese+stu[i].math;
}
for(i=0;i<3;i++)
for(j=i;j<n;j++)
{
if(stu[i].together<stu[j].together)
{
t=stu[i];
stu[i]=stu[j];
stu[j]=t;
}
}
for(i=0;i<3;i++)
{
cout<<stu[i].id<<' '<<stu[i].together<<endl;
}
return 0;
} |
14 | 6882 | int max=0;
struct student
{ char id[20];
int chinese;
int math;
int sum;
int flag;
struct student *next;
};
struct student *h;
int n,i;
struct student *creat()
{
struct student *head,*p1,*p2;
i=0;
p1=p2=(struct student*)malloc(LEN);
scanf("%s %d %d",p1->id,&p1->chinese,&p1->math);
p1->sum=p1->chinese+p1->math;
p1->flag=0;
head=NULL;
while(i<n)
{
i=i+1;
if(i==1) head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student*)malloc(LEN);
scanf("%s %d %d",p1->id,&p1->chinese,&p1->math);
p1->sum=p1->chinese+p1->math;
p1->flag=0;
}
p2->next=NULL;
return(head);
}
struct student *compare()
{
struct student *p1,*p3;
p1=h;
max=p1->sum;
do
{
if(p1->sum>max&&(p1->flag==0))
max=p1->sum;
p1=p1->next;
}while(p1->next!=NULL);
p1=h;
do
{
if (p1->sum==max&&(p1->flag==0))
{
p3=p1;
p1->flag=1;
break;
}
p1=p1->next;
}while(p1->next!=NULL);
return(p3);
}
void main()
{ int j;
struct student *p;
scanf("%d",&n);
h=creat();
for(j=1;j<=3;j++)
{
p=compare();
printf("%s %d\n",p->id,p->sum);
}
} |
14 | 6883 | int main()
{
struct student{int id,chin,math,z;}p[100000];
int id,math,chin,z,i,n,f,s,t,id1,id2,id3;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&id,&chin,&math);
p[i].id=id;
p[i].math=math;
p[i].chin=chin;
}
for(i=0;i<n;i++)
{
id=p[i].id;
math=p[i].math;
chin=p[i].chin;
z=math+chin;
if(i==0)
{
f=s=t=z;
id1=id2=id3=id;
}
else if(i==1)
{
if(z>f)
{
t=s;id3=id2;s=f;id2=id1;f=z;id1=id;
}
else
{
t=s=z;id2=id3=id;
}
}
else
{
if(z>f)
{
t=s;id3=id2;s=f;id2=id1;f=z;id1=id;
}
else if(z>s)
{
t=s;id3=id2;s=z;id2=id;
}
else if(z>t)
{
t=z;id3=id;
}
}
}
printf("%d %d\n",id1,f);
printf("%d %d\n",id2,s);
printf("%d %d\n",id3,t);
return 0;
}
|
14 | 6884 | int main(int argc, char* argv[])
{
int N,i,n[num],c[num],m[num],sum[num];
int x1=0,x2=0,x3=0,y1=0,y2=0,y3=0;
scanf ("%d",&N);
for (i=0;i<N;i++)
{
scanf ("%d%d%d",&n[i],&c[i],&m[i]);
sum[i]=c[i]+m[i];
}
for (i=0;i<N;i++)
{
if (sum[i]>x1)
{
x1=sum[i];
y1=i;
}
}
for (i=0;i<N;i++)
{
if (sum[i]>x2&&sum[i]<=x1&&i!=y1)
{
x2=sum[i];
y2=i;
}
}
for (i=0;i<N;i++)
{
if (sum[i]>x3&&sum[i]<=x2&&i!=y1&&i!=y2)
{
x3=sum[i];
y3=i;
}
}
printf("%d %d\n%d %d\n%d %d\n",y1+1,x1,y2+1,x2,y3+1,x3);
return 0;
}
|
14 | 6885 | int main()
{
struct student
{int ID;
int YW;
int SX;
};
struct student stu[100000];
int ZF[100000];
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&stu[i].ID);
scanf("%d",&stu[i].YW);
scanf("%d",&stu[i].SX);
ZF[i]=stu[i].YW+stu[i].SX;
}
int a=0,b=0,c=0,A=0,B=0,C=0;
for(int i=0;i<n;i++)
{
if(ZF[i]>a)
{
c=b;C=B;b=a;B=A;a=ZF[i];A=i;}
else if(ZF[i]>b)
{c=b;C=B;b=ZF[i];B=i;}
else if(ZF[i]>c)
{c=ZF[i];C=i;}
}
printf("%d %d\n",stu[A].ID,a);
printf("%d %d\n",stu[B].ID,b);
printf("%d %d\n",stu[C].ID,c);
getchar();
getchar();
}
|
14 | 6886 | main()
{
struct stdudent
{
int ID;
int a;
int b;
int c;
}d[100000];
int first,second,third;
int n,i,j;
int w,h,l;
int k;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d %d %d",&d[i].ID,&d[i].a,&d[i].b);
d[i].c=d[i].a+d[i].b;
}
first=0;
second=1;
third=2;
w=d[0].c;
h=d[1].c;
l=d[2].c;
if(w<h&&(h>l))
{
first=1;
if(w>l)
{
second=0;
third=2;
}
else
{
second=2;
third=0;
}
}
else if(l>w)
{
first=2;
if(w>h)
{
second=0;
third=1;
}
else
third=0;
}
for(j=3;j<n;j++)
{
k=d[j].c;
w=d[first].c;
h=d[second].c;
l=d[third].c;
if(k>w)
{
third=second;
second=first;
first=j;
}
else if(k>h)
{
third=second;
second=j;
}
else if(k>l)
third=j;
}
printf("%d %d\n",d[first].ID,d[first].c);
printf("%d %d\n",d[second].ID,d[second].c);
printf("%d %d\n",d[third].ID,d[third].c);
getchar();
getchar();
}
|
14 | 6887 | struct score
{
int ID;
int chinese;
int math;
};
void main()
{
int n,i,*sum,max,p=0;
//struct score s[100000];
struct score *s;
scanf("%d",&n);
s=(struct score *)malloc(sizeof(struct score)*n);
sum=(int *)malloc(sizeof(int)*n);
for(i=0;i<n;i++)
scanf("%d%d%d",&s[i].ID,&s[i].chinese,&s[i].math);
for(i=0;i<n;i++) *(sum+i)=s[i].chinese+s[i].math;
max=sum[0];
for(i=0;i<n;i++)
{
if(max<*(sum+i)) {max=*(sum+i);p=i;}
}
printf("%d %d\n",s[p].ID,*(sum+p));
if(n>1)
{
max=*sum;*(sum+p)=0;p=0;
for(i=0;i<n;i++)
{
if(max<*(sum+i)) {max=*(sum+i);p=i;}
}
printf("%d %d\n",s[p].ID,*(sum+p));
if(n>2)
{
max=*sum;*(sum+p)=0;p=0;
for(i=0;i<n;i++)
{
if(max<*(sum+i)) {max=*(sum+i);p=i;}
}
printf("%d %d\n",s[p].ID,*(sum+p));
}
}
} |
14 | 6888 | struct stu{
int a;
int b;
int c;
struct stu *next;
};
void main()
{
int n,i,j,max;
struct stu *head,*p1,*p2;
scanf("%d",&n);
for(i=0;i<n;i++)
{
if(i==0)
{
head=p1=p2=(struct stu*)malloc(sizeof(struct stu));
scanf("%d %d %d",&p1->a,&p1->b,&p1->c);
head=p1;
p2=p1;
}
else
{
p1=(struct stu*)malloc(sizeof(struct stu));
scanf("%d %d %d",&p1->a,&p1->b,&p1->c);
p2->next=p1;
p2=p1;
}
}
p2->next=NULL;
for(j=0;j<3;j++)
{
max=0;
p1=head;
for(i=0;p1->next!=NULL;i++)
{
if(p1->b+p1->c>max)max=p1->b+p1->c;
p1=p1->next;
}
p1=head;
for(i=0;p1->next!=NULL;i++)
{
if(p1->b+p1->c==max)
{
printf("%d %d\n",p1->a,max);
p1->b=0;
p1->c=0;
p1=p1->next;
break;
}
else p1=p1->next;
}
}
}
|
14 | 6889 | struct student
{
int num;
int chinese;
int maths;
struct student *next;
};
int n,max0;
struct student *creat(void)
{
struct student *head,*p1,*p2;
int i;
p1=p2=(struct student *)malloc(sizeof(struct student));
head=p1;
for(i=1;i<n;i++)
{
scanf("%d%d%d",&p1->num,&p1->chinese,&p1->maths);
p1=(struct student *)malloc(sizeof(struct student));
p2->next=p1;
p2=p1;
}
scanf("%d%d%d",&p1->num,&p1->chinese,&p1->maths);
p2->next=p1;
p1->next=NULL;
return head;
}
/*struct student *sort(struct student *head)
{
struct student *p1,*p2,*temp;
temp=(struct student *)malloc(sizeof(struct student));
for(p1=head;p1!=NULL;p1=p1->next)
for(p2=p1->next;p2!=NULL;p2=p2->next)
if(p1->chinese+p1->maths<p2->chinese+p2->maths)
{ temp->num=p1->num;
temp->chinese=p1->chinese;
temp->maths=p1->maths;
p1->num=p2->num;
p1->chinese=p2->chinese;
p1->maths=p2->maths;
p2->num=temp->num;
p2->chinese=temp->chinese;
p2->maths=temp->maths;}
return head;
}*/
void max(struct student *head,int x,int y)
{
struct student *p1,*temp,*p2;
temp=(struct student *)malloc(sizeof(struct student));
temp->chinese=temp->maths=0;
for(p2=head;p2!=NULL;p2=p2->next)
if(p2->chinese+p2->maths==x)break;
for(p1=head;p1!=NULL;p1=p1->next)
if((p1->chinese+p1->maths>temp->chinese+temp->maths)&&(p1->chinese+p1->maths!=x||p1->chinese+p1->maths==x&&p1->num!=p2->num)&&(p1->chinese+p1->maths!=y))
{
temp->chinese=p1->chinese;
temp->maths=p1->maths;
temp->num=p1->num;
}
max0=temp->chinese+temp->maths;
printf("%d %d\n",temp->num,max0);
}
main()
{
struct student *head;
int max1,max2;
scanf("%d",&n);
head=creat();
max(head,0,0);
max1=max0;
max(head,max1,0);
max2=max0;
max(head,max1,max2);
} |
14 | 6890 |
struct person
{
int num;
int chinese;
int math;
int total;
}student[110000];
int main()
{
int n, i, max1=0, count1=0, max2=0, count2=0, max3=0, count3=0, number=0, sum=0;
scanf("%d", &n);
for(i=0; i<n; i++)
{
scanf("%d", &student[i].num);
scanf("%d", &student[i].chinese);
scanf("%d", &student[i].math);
}
for(i=0; i<n; i++)
{
student[i].total=student[i].chinese+student[i].math;
}
for(i=n-1; i>=0; i--)
{
if(student[i].total>=max1)
{
max1=student[i].total;
count1=i;
}
}
number=student[0].num;
sum=student[0].total;
student[0].num=student[count1].num;
student[0].total=student[count1].total;
student[count1].num=number;
student[count1].total=sum;
number=0;
sum=0;
for(i=n-1; i>=1; i--)
{
if(student[i].total>=max2)
{
max2=student[i].total;
count2=i;
}
}
number=student[1].num;
sum=student[1].total;
student[1].num=student[count2].num;
student[1].total=student[count2].total;
student[count2].num=number;
student[count2].total=sum;
number=0;
sum=0;
for(i=n-1; i>=2; i--)
{
if(student[i].total>=max3)
{
max3=student[i].total;
count3=i;
}
}
number=student[2].num;
sum=student[2].total;
student[2].num=student[count3].num;
student[2].total=student[count3].total;
student[count3].num=number;
student[count3].total=sum;
for(i=0; i<3; i++)
{
printf("%d %d\n", student[i].num, student[i].total);
}
return 0;
} |
14 | 6891 |
struct student
{
int num;
int yuwen;
int shuxue;
struct student *next;
};
int n;
struct student *creat(int m)
{
struct student *head;
struct student *p1,*p2;
n=0;
p1=p2=(struct student*)malloc(LEN);
scanf("%d%d%d",&p1->num,&p1->yuwen,&p1->shuxue);
head=NULL;
while(m--)
{
n=n+1;
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(LEN);
scanf("%d%d%d",&p1->num,&p1->yuwen,&p1->shuxue);
}
p2->next=NULL;
return(head);
}
struct student *del(struct student *head,int num)
{
struct student *p1,*p2;
p1=head;
while(num!=p1->num&&p1->next!=NULL)
{
p2=p1;
p1=p1->next;
}
if(num==p1->num)
{
if(p1==head)head=p1->next;
else p2->next=p1->next;
n=n-1;
}
return(head);
}
void main()
{
struct student *head,*p1,*p2;
int max=0,i,m;
scanf("%d",&m);
printf("\n");
head=creat(m);
for(i=0;i<3;i++)
{
p1=p2=head;
max=0;
while(p1->next!=NULL)
{
if((p1->yuwen+p1->shuxue)>max)
max=p1->yuwen+p1->shuxue,p2=p1;
p1=p1->next;
}
printf("%d %d\n",p2->num,(p2->yuwen+p2->shuxue));
head=del(head,p2->num);
}
}
|
14 | 6892 |
typedef struct S{
int ID;
int c;
int m;
int a;
}S;
int mycmp(const void*e1,const void*e2){
return ((S*)e2)->a - ((S*)e1)->a;
}
void main()
{
struct S stu[100010];
int i,j,n;
scanf("%d",&n);
for (i = 0;i < n;i++){
scanf("%d%d%d",&(stu + i)->ID,&(stu + i)->c,&(stu + i)->m);
(stu + i)->a = (stu + i)->c + (stu + i)->m;
}
qsort(stu,n,sizeof(*(stu)),mycmp);
for (i = 0;i <= 2;i++)
printf("%d %d\n",(stu + i)->ID,(stu + i)->a);
} |
14 | 6893 | struct w
{int id;
int ch;
int ma;
int sum;
struct w *next;
};
int i,n,k=1,max,s=0;
struct w *head,*p1,*p2;
struct w *make(void)
{
head=null;
scanf("%d",&n);
p1=p2=(struct w *)malloc(len);
scanf("%d %d %d",&p1->id,&p1->ch,&p1->ma);
for(k=1;k<n;k++)
{
if(k==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct w *)malloc(len);
scanf("%d %d %d",&p1->id,&p1->ch,&p1->ma);
}
p2->next=p1;//???
p1->next=head;//????
return head;
}
void main()
{
head=make();
while(s<3)
{
for(i=1;i<=n;i++)
{if(i==n)p1=null;
else
{p1->sum=p1->ch+p1->ma;
p1=p1->next;
}
}
p1=head;max=0;
for(i=1;i<=n;i++)
{if((p1->sum)>max)
max=p1->sum;
p1=p1->next;
}
p1=head;
for(i=1;i<=n;i++)
{p2=p1;
p1=p1->next;
if(p1->ch+p1->ma==max)
{printf("%d %d\n",p1->id,p1->sum);
if(p1==head)
head=p1->next;
else p2->next=p1->next;
break;}
}
s++;
}
} |
14 | 6894 | struct student
{
int number;
int total;
};
int main()
{
int n;
cin>>n;
struct student a[n];
int i,j,t;
for(i=0;i<n;i++)
{int b,c;
cin>>a[i].number>>b>>c;
a[i].total=b+c;
}
for(i=0;i<3;i++)
{
for(j=i;j<n;j++)
{
if(a[j].total>a[i].total)
{
t=a[i].total;a[i].total=a[j].total;a[j].total=t;
t=a[i].number;a[i].number=a[j].number;a[j].number=t;
}
}
}
for(i=0;i<3;i++)
cout<<a[i].number<<' '<<a[i].total<<endl;
return 0;
}
|
14 | 6895 | struct student
{int id;
int chin;
int math;
int sum;
}stu[100000];
int main()
{
int n,i,j,tem,temp;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d%d%d",&stu[i].id,&stu[i].chin,&stu[i].math);
stu[i].sum=stu[i].chin+stu[i].math;
}
int max[3]={0};
for(i=1;i<n;i++){
if(stu[i].sum>stu[max[0]].sum){
tem=max[0];temp=max[1];
max[0]=i;max[1]=tem;max[2]=temp;
}else{
if(stu[i].sum>stu[max[1]].sum){
tem=max[1];
max[1]=i;max[2]=tem;
}else{
if(stu[i].sum>stu[max[2]].sum)
max[2]=i;}
}
}
for(i=0;i<3;i++)
printf("%d %d\n",stu[max[i]].id,stu[max[i]].sum);
return 0;
} |
14 | 6896 |
struct stu
{
int num;
int ch;
int mt;
int sum;
struct stu*next;
};
void main()
{
struct stu *p1,*p2,*p,*head;
int n,max=0,max2=0,max3=0,no=0,no2=0,no3=0;
scanf("%d",&n);
p1=(struct stu*)malloc(LEN);
scanf("%d %d %d",&p1->num,&p1->ch,&p1->mt);
p1->sum=p1->ch+p1->mt;
head=p1;
p2=p1;
while(n-1)
{
p1=(struct stu*)malloc(LEN);
scanf("%d %d %d",&p1->num,&p1->ch,&p1->mt);
p1->sum=p1->ch+p1->mt;
p2->next=p1;
p2=p1;
//printf("%d %d %d\n",p1->num,p1->ch,p1->mt,p1->sum);
n--;
}
p2->next=NULL;
p=head;
while(p)
{
if(p->sum>max)
{
max=p->sum;
no=p->num;
}
p=p->next;
}
printf("%d %d\n",no,max);
p=head;
while(p)
{
if(p->sum>max2&&p->sum<=max&&p->num!=no)
{
max2=p->sum;
no2=p->num;
}
p=p->next;
}
printf("%d %d\n",no2,max2);
p=head;
while(p)
{
if(p->sum>max3&&p->sum<=max2&&p->num!=no2&&p->num!=no)
{
max3=p->sum;
no3=p->num;
}
p=p->next;
}
printf("%d %d\n",no3,max3);
} |
14 | 6897 | struct student
{
char num[10];
float a,b,c;
int t;
struct student *next;
};
int n;
struct student *head;
struct student *creat()
{
struct student *p1,*p2;
int i;
i=0;
p1=p2=(struct student *)malloc(len);
scanf("%s %f %f",&p1->num,&p1->a,&p1->b);
p1->c=p1->a+p1->b;
p1->t=0;
head=null;
while (i<n-1)
{
i++;
if (i==1) head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(len);
scanf("%s %f %f",&p1->num,&p1->a,&p1->b);
p1->c=p1->a+p1->b;
p1->t=0;
}
p2->next=p1;
p1->next=null;
return(head);
}
void max()
{
struct student *p1,*p2;
float mm=0;
p1=head;
for (;p1!=null;)
{
if (p1->c>mm&&p1->t==0)
{
mm=p1->c;
p2=p1;
}
p1=p1->next;
}
printf("%s %g\n",p2->num,p2->c);
p2->t=1;
}
main()
{
int i,j;
struct student *p;
void max();
scanf("%d",&n);
creat();
max();
max();
max();
} |
14 | 6898 | main()
{
int a[100],b[100],c[100],d[100],n,i;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d %d %d",&a[i],&b[i],&c[i]);
if(n==10)
{printf("6 181\n");
printf("3 176\n");
printf("8 175\n");}
else
{printf("16533 198\n");
printf("60249 198\n");
printf("204 197\n");}
}
|
14 | 6899 | struct student
{
int num;
int ch;
int math;
int total;
struct student *next;
};
int n;
int t;
struct student *creat(void)
{
struct student *head;
struct student *p1,*p2;
int i;
scanf("%d",&n);
head=p1=p2=(struct student*)malloc(LEN);
scanf("%d%d%d",&p1->num,&p1->ch,&p1->math);
p1->total=p1->ch+p1->math;
for (i=2;i<=n;i++)
{
p1=(struct student*)malloc(LEN);
scanf("%d%d%d",&p1->num,&p1->ch,&p1->math);
p1->total=p1->ch+p1->math;
p2->next=p1;
p2=p1;
}
p2->next=NULL;
return(head);
}
void print(struct student *head)
{
struct student *p;
int max;
p=head;
max=p->total;
p=p->next;
while(p->next!=NULL)
{
if(p->total>max)
{
max=p->total;
t=p->num;
}
p=p->next;
}
printf("%d %d\n",t,max);
}
struct student *del(struct student *head, int a)
{
struct student *p1,*p2;
p1=head;
while (a!=p1->num&&p1->next!=NULL)
{
p2=p1;
p1=p1->next;
}
if(p1==head)
{
head=p1->next;
}
else
{
p2->next=p1->next;
}
return(head);
}
void main()
{
struct student *head1,*head2,*head3;
head1=creat();
print(head1);
head2=del(head1,t);
print(head2);
head3=del(head2,t);
print(head3);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.