id
int32 0
32.5k
| code
stringlengths 95
8.4k
| label
stringclasses 65
values |
---|---|---|
4,000 | int main()
{
int a[100],i,e,k;
char id[100][10],p[10];
int n;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s%d",id[i],&a[i]);
}
for(k=1;k<=n;k++){
for(i=n-1;i>k-1;i--){
if(a[i]>a[i-1]&&a[i]>=60){
e=a[i];
a[i]=a[i-1];
a[i-1]=e;
strcpy(p,id[i]);
strcpy(id[i],id[i-1]);
strcpy(id[i-1],p);
}
}
}
for(i=0;i<n;i++){
printf("%s\n",id[i]);
}
return 0;
}
| 9 |
4,001 |
struct patient
{
char id[10];
int age;
struct patient *next;
};
struct patient *sort(struct patient *head,char d[10],int a)
{
struct patient *pp,*p,*s;
p=head;
pp=p;
p=p->next;
s=(struct patient *)malloc(LEN);
strcpy(s->id,d);
s->age=a;
while(p!=NULL&&p->age>=a)
{
pp=p;
p=p->next;
}
s->next=p;
pp->next=s;
}
struct patient *creat(struct patient *hhead,char d[10],int a)
{
struct patient *p,*pp,*s;
p=hhead;
pp=p;
p=p->next;
while(p!=NULL)
{
pp=p;
p=p->next;
}
s=(struct patient*)malloc(LEN);
s->age=a;
strcpy(s->id,d);
s->next=p;
pp->next=s;
}
void main()
{
struct patient *head,*hhead,*p1,*p2;
int n,a,i;
char d[10];
scanf("%d",&n);
head=(struct patient*)malloc(LEN);
head->next=NULL;
hhead=(struct patient*)malloc(LEN);
hhead->next=NULL;
for(i=0;i<n;i++)
{
scanf("%s %d\n",d,&a);
if(a>=60)
sort(head,d,a);
else creat(hhead,d,a);
}
p1=head->next;
p2=hhead->next;
while(p1!=NULL)
{
printf("%s\n",p1->id);
p1=p1->next;
}
while(p2!=NULL)
{
printf("%s\n",p2->id);
p2=p2->next;
}
}
| 9 |
4,002 | int main()
{
int n,i,j,k=0,m=0,t,x;
char w[10];
scanf("%d",&n);
struct patient
{char id[10];
int age;
}a[100];
for(i=0;i<n;i++)
scanf("%s%d",a[i].id,&a[i].age); /*?????*/
struct patient1
{char id[10];
int age;
}b[100];
struct patient2
{char id[10];
int age;
}c[100];
for(i=0;i<n;i++)
{
if(a[i].age>=60)
{
b[k].age=a[i].age;
for(j=0;j<10;j++)
{
b[k].id[j]=a[i].id[j];
}
k++;
} /*???????patient1????*/
else
{
c[m].age=a[i].age;
for(j=0;j<10;j++)
{
c[m].id[j]=a[i].id[j];
}
m++;
}
} /*?????????patient2,???*/
for(j=0;j<k-1;j++)
{
for(i=0;i<k-1-j;i++)
{
if(b[i].age<b[i+1].age)
{
t=b[i].age;
b[i].age=b[i+1].age;
b[i+1].age=t;
for(x=0;x<10;x++)
{
w[x]=b[i].id[x];
b[i].id[x]=b[i+1].id[x];
b[i+1].id[x]=w[x];
}
}
}
} /*???patient1?age???????id*/
for(i=0;i<k;i++)
printf("%s\n",b[i].id); /*??patient1*/
for(i=0;i<m;i++)
printf("%s\n",c[i].id); /*??patient2*/
return 0;
}
| 9 |
4,003 | struct patient
{
char num[10];
int age;
}pat[100];
int main()
{
int n,i,m,k,f,j;
char e[10];
m=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s%d",&pat[i].num,&pat[i].age);
if(pat[i].age>=60){
strcpy(e,pat[i].num);
f=pat[i].age;
for(k=i;k>m;k--){
strcpy(pat[k].num,pat[k-1].num);
}strcpy(pat[m].num,e);
pat[m].age=f;
m++;
}
}for(i=0;i<m;i++){
for(k=0;k<i;k++){
if(pat[i].age>pat[k].age){
f=pat[i].age;
strcpy(e,pat[i].num);
for(j=i;j>k;j--){
pat[j].age=pat[j-1].age;
strcpy(pat[j].num,pat[j-1].num);
}pat[k].age=f;
strcpy(pat[k].num,e);
}
}
}
for(i=0;i<n;i++){
printf("%s\n",pat[i].num);
}
return 0;
} | 9 |
4,004 | int main(){
int i,j=0,k,m,n,e,x,s[100],t[100],v=0;
char zfc[100][10],jg[100][10],h[100][10];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s",zfc[i]);
scanf("%d",&s[i]);
}
for(i=0;i<n;i++){
if(s[i]>=60){
t[j]=i;
j++;
}
}
for(i=j;i>=0;i--){
for(k=0;k<i-1;k++){
if(s[t[k]]<s[t[k+1]]){
m=t[k+1];
t[k+1]=t[k];
t[k]=m;
}
}
}
for(i=0;i<j;i++){
puts(zfc[t[i]]);
}
for(i=0;i<n;i++){
if(s[i]<60){
puts(zfc[i]);
}
}
return 0;
}
| 9 |
4,005 | int main()
{
char s[100][100],a[100][100],b[100];
int n,i,j=0,sz[100],t,c;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s %d",s[i],&sz[i]);}
for(i=0;i<n;i++){
if(sz[i]<60){
strcpy(a[j],s[i]);
j++;}}
for(t=1;t<=n;t++){
for(i=0;i<n-t;i++){
if(sz[i]<sz[i+1]){
c=sz[i+1];sz[i+1]=sz[i];sz[i]=c;
strcpy(b,s[i+1]);
strcpy(s[i+1],s[i]);
strcpy(s[i],b);}}}
for(i=0;i<n;i++){
if(sz[i]>=60){
printf("%s\n",s[i]);}}
for(i=0;i<j;i++){
printf("%s\n",a[i]);}
return 0;
}
| 9 |
4,006 | int main()
{
int n,i,j,k,e,age[100],six[100];
j=0;
char id[100][10];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s",&id[i]);
scanf("%d",&age[i]);
if(age[i]>=60){
six[j]=i;
j++;
}
}
for(i=j;i>=0;i--){
for(k=0;k<i-1;k++){
if(age[six[k]]<age[six[k+1]]){
e=six[k+1];
six[k+1]=six[k];
six[k]=e;
}
}
}
for(i=0;i<j;i++)
printf("%s\n",id[six[i]]);
for(i=0;i<n;i++){
if(age[i]<60)
printf("%s\n",id[i]);
}
return 0;
}
| 9 |
4,007 | int main(){
int n,i,j;
struct {
int y,a;
char id[10];
}p[100],t;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s %d",p[i].id,&p[i].y);
p[i].a=i+1;
}
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
if(p[i].y>=60||p[j].y>=60)
{
if(p[j].y>p[i].y)
{
t=p[i];
p[i]=p[j];
p[j]=t;
}
else if(p[i].y==p[j].y)
{
if(p[j].a<p[i].a){
t=p[i];
p[i]=p[j];
p[j]=t;
}
}
}
else{
if(p[j].a<p[i].a){
t=p[i];
p[i]=p[j];
p[j]=t;
}
}
}
}
for(i=0;i<n;i++){
printf("%s\n",p[i].id);
}
return 0;
}
| 9 |
4,008 |
struct peo{
char id[11];
int age;
};
int main(){
struct peo people[100];
struct peo sixty[100];
int n,b=0,i,j,k,e;
char a[11];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s %d",people[i].id,&people[i].age);
if(people[i].age>=60){
sixty[i].age=people[i].age;
strcpy(sixty[i].id,people[i].id);
b+=1;
}else{
strcpy(sixty[i].id,"0000");
sixty[i].age=0;
}
}
for(k=0;k<n-1;k++){
for(i=n-1;i>k;i--){
if(sixty[i-1].age<sixty[i].age){
e=sixty[i-1].age;
sixty[i-1].age=sixty[i].age;
sixty[i].age=e;
strcpy(a,sixty[i-1].id);
strcpy(sixty[i-1].id,sixty[i].id);
strcpy(sixty[i].id,a);
}
}
}
for(i=0;i<b;i++){
printf("%s\n",sixty[i].id);
}
for(i=0;i<n;i++){
if(people[i].age<60){
printf("%s\n",people[i].id);
}
}
return 0;
}
| 9 |
4,009 |
int num,n=0;
struct pa
{
char id[10];
int age;
int o;
}*p;
int operate()
{
struct pa *pi,*pj;
int agem=0,om=0;
for(pi=p;pi<p+num;pi++)
{
if(pi->o==0)
continue;
for(pj=p;pj<p+num;pj++)
{
if(pj->o==0)
continue;
if(pj->age<pi->age)
pi->o++;
}
if(pi->o>om)
om=pi->o;
}
return om;
}
void print(int om)
{
int k;
struct pa *pi;
for(k=om;k>=0;k--)
for(pi=p;pi<p+num;pi++)
{
if(pi->o==k)
{
if(n==0)
{
printf("%s",pi->id);
n++;
}
else
printf("\n%s",pi->id);
}
}
}
main()
{
scanf("%d",&num);
struct pa *pi;
int om;
p=(struct pa*)malloc(num*sizeof(struct pa));
for(pi=p;pi<p+num;pi++)
{
scanf("%s %d",pi->id,&pi->age);
if(pi->age>=60)
pi->o=1;
else pi->o=0;
}
om=operate();
print(om);
}
| 9 |
4,010 |
//#include <math.h>
int main()
{
int n;
scanf("%d",&n);
struct pe{
char id[100];
int y;
}*p;
p=(struct pe *)malloc(sizeof(pe)*n);
int i,j;
for(i=0;i<n;i++){
scanf("%s %d",(p+i)->id,&(p+i)->y);
}
struct pe tp;
for(i=n-1;i>0;i--){
for(j=0;j<i;j++){
if((p+j+1)->y>=60 && (p+j)->y<(p+j+1)->y){
tp=p[j+1];
p[j+1]=p[j];
p[j]=tp;
}
}
}
for(i=0;i<n;i++){
printf("%s\n",(p+i)->id);
}
return 0;
}
| 9 |
4,011 | struct patient
{
char id[10];
int age;
}pat[100],p[100];
void main()
{
int n,m=0,i,j=0,k,temp,a[40]={0},sum=1;
scanf("%d\n",&n);
for(i=0;i<n;i++)
scanf("%s%d",pat[i].id,&pat[i].age);
for(i=0;i<n;i++)
{
if(pat[i].age>=60)
{ p[j++]=pat[i];m++;}
}
a[0]=p[0].age;
for(j=1;j<m;j++)
{ for(i=0;a[i]!=0;i++)
if(a[i]==p[j].age)break;
if(a[i]==0)
{a[i]=p[j].age;sum++;}
}
for(j=0;j<sum-1;j++)
{
k=j;
{
for(i=j+1;i<sum;i++)
if(a[i]>a[j])
{k=i;
temp=a[k];a[k]=a[j];a[j]=temp;}
}
}
for(k=0;k<sum;k++)
{ for(j=0;j<m;j++)
{
if(p[j].age==a[k])printf("%s\n",p[j].id);
}
}
for(i=0;i<n;i++)
{
if(pat[i].age<60)
printf("%s\n",pat[i].id);
}
} | 9 |
4,012 | struct Patient
{
char id[10];
int age;
int num;
}patient[100];
int main ()
{
int n;
int a,b,c;
scanf ("%d", &n);
int i,j,k=0;
for (i=0;i<=n-1;i++)
{
scanf ("%s %d", &patient[i].id, &patient[i].age);
patient[i].num = i;
}
int s[100];
for (i=0;i<=99;i++)
{
s[i]=i;
}
for (i=0;i<=n-2;i++)
{
for (j=0;j<=n-2;j++)
{
if (patient[s[j]].age<patient[s[j+1]].age)
{
a=s[j];
s[j]=s[j+1];
s[j+1]=a;
}
}
}
for (i=0;i<=n-1;i++)
{
if (patient[i].age>=60)
k=k+1;
}
for (i=0;i<=k-2;i++)
{
for (j=0;j<=k-2;j++)
{
if (s[j]>s[j+1] && patient[s[j]].age==patient[s[j+1]].age)
{
a=s[j];
s[j]=s[j+1];
s[j+1]=a;
}
}
}
for (i=k;i<=n-2;i++)
{
for (j=k;j<=n-2;j++)
{
if (s[j]>s[j+1])
{
a=s[j];
s[j]=s[j+1];
s[j+1]=a;
}
}
}
for (i=0;i<=n-1;i++)
{
printf ("%s\n", patient[s[i]].id);
}
return 0;
}
| 9 |
4,013 | struct patient{
char id[10];
int age;
struct patient* next;
struct patient* last;
};
char temp[10];
int main()
{
struct patient *p1,*p2,*head,p[N];
int n,i,j,tmp;
scanf("%d",&n);
memset(p,0,sizeof(p));
head=p+1;
for(i=1;i<=n;i++)
{
scanf("%s %d",p[i].id,&p[i].age);
p[i].last=p+i-1;
p[i].next=p+i+1;
}
head->last=NULL;
p[i].next=NULL;
for(i=n;i>1;i--)
{
for(j=1;j<n;j++)
{
if((p+j+1)->age>=60&&(p+j+1)->age>(p+j)->age)
{
memcpy(temp,(p+j)->id,sizeof(temp));
memcpy((p+j)->id,(p+j+1)->id,sizeof(temp));
memcpy((p+j+1)->id,temp,sizeof(temp));
tmp=(p+j)->age;
(p+j)->age=(p+j+1)->age;
(p+j+1)->age=tmp;
}
}
}
for(;head!=NULL;head=head->next)
printf("%s\n",head->id);
} | 9 |
4,014 |
typedef struct
{
char ID[10];
int age;
}patient;
patient pat[100];
int cmp(const void*, const void*);
int main()
{
int n;
int i;
scanf("%d",&n);
for (i=0;i<n;i++)
{
scanf("%s",pat[i].ID);
scanf("%d",&pat[i].age);
}
qsort(pat,n,sizeof(patient),cmp);
for (i=0;i<n;i++)
{
printf("%s\n",pat[i].ID);
}
return 0;
}
int cmp(const void *_p1, const void *_p2)
{
patient *p1 = (patient*)_p1;
patient *p2 = (patient*)_p2;
if (p1->age>=60 && p1->age<60)
return -1;
else if (p1->age<60 && p2->age >= 60)
return 1;
else if (p1->age>=60 && p2->age >= 60)
return p2->age - p1->age;
else
return 0;
}
| 9 |
4,015 | int main()
{
int n,k,i,j,l;
int a[100],c[100],d[100];
char b[100][11];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s",b[i]);
scanf("%d",&a[i]);
d[i]=a[i];
c[i]=i;
}
for(j=0;j<n;j++)
{
for(i=0;i<n-1;i++)
{
if(d[i]<d[i+1])
{
k=d[i];
d[i]=d[i+1];
d[i+1]=k;
k=c[i];
c[i]=c[i+1];
c[i+1]=k;
}
}
}
for(j=0;j<n;j++)
{
if(d[j]<60)
{
l=j;
break;
}
}
for(j=0;j<l;j++)
{
k=c[j];
printf("%s\n",b[k]);
}
for(i=0;i<n;i++)
{
if(a[i]<60)
{
printf("%s\n",b[i]);
}
}
return 0;
}
| 9 |
4,016 | int main()
{
struct patient
{
int id[7];
int age;
}patient[100];
int i,n,max=0,k;
scanf("%d\n",&n);
for(i=0;i<n;i++)scanf("%s %d\n",patient[i].id,&patient[i].age);
for(i=0;i<n;i++)
{
if(patient[i].age>max)max=patient[i].age;
}
for(k=max;k>59;k--)
{
for(i=0;i<n;i++)if(patient[i].age==k)printf("%s\n",patient[i].id);
}
for(i=0;i<n;i++)
{
if(patient[i].age<60)printf("%s\n",patient[i].id);
}
} | 9 |
4,017 | struct bingren
{
char id[20];
int nian;
struct bingren *next;
};
int main()
{
int n,i;
struct bingren *p1,*head;
struct bingren temp;
char a[20]={'\0'};
int b=0;
scanf("%d",&n);
head=(struct bingren *)malloc(sizeof(struct bingren));
head->next=NULL;
scanf("%s%d",head->id,&head->nian);
p1=head;
for(i=1;i<n;i++)
{
p1->next=(struct bingren *)malloc(sizeof(struct bingren));
scanf("%s%d",p1->next->id,&p1->next->nian);
p1->next->next=NULL;
p1=p1->next;
}
p1=head;
for(i=1;i<n;i++)
{
for(;p1->next!=NULL;)
{
if(p1->next->nian >= 60 && p1->next->nian > p1->nian )
{
b=p1->nian;
p1->nian=p1->next->nian;
p1->next->nian=b;
strcpy(a,p1->id);
strcpy(p1->id,p1->next->id);
strcpy(p1->next->id,a);
}
p1=p1->next;
}
p1=head;
}
p1=head;
for(;p1!=NULL;)
{
printf("%s\n",p1->id);
p1=p1->next;
}
}
| 9 |
4,018 | void main()
{
int n,i,j,k,m=0,sum=59;
int a[100],b[100];
char c[101][10];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s %d",c[i],&a[i]);
if(a[i]>=60) m++;
}
for(j=0;j<m;j++)
{
for(i=0;i<n;i++)
{
if(a[i]>sum)
{
sum=a[i];
k=i;
}
else continue;
}
a[k]=-1;
b[j]=k;
sum=59;
}
for(i=0;i<m;i++)
printf("%s\n",c[b[i]]);
for(i=0;i<n;i++)
{
if(a[i]>=0&&a[i]<60)
printf("%s\n",c[i]);
}
} | 9 |
4,019 | int main()
{
struct patients
{
char id[10];
int age;
}temp;
struct patients patient[100];
struct patients old[100];
int i,j,n,first;
scanf("%d",&n);
first=0;
for (i=0;i<n;i++){
scanf("%s",patient[i].id);
scanf ("%d",&patient[i].age);
if (patient[i].age>=60){
old[first]=patient[i];
first=first+1;
}
}
for (i=0;i<first;i++){
for (j=0;j<first-i-1;j++){
if (old[j].age<old[j+1].age){
temp=old[j];
old[j]=old[j+1];
old[j+1]=temp;
}
}
}
for (i=0;i<first;i++){
printf("%s\n",old[i].id);
}
for (i=0;i<n;i++){
if (patient[i].age<60){
printf("%s\n",patient[i].id);
}
}
return 0;
}
| 9 |
4,020 | struct patient
{ char id[11];
int age;
};
int main()
{ struct patient pt[100];
int n,i,j,a=0,b=0,tem;
int age_r[100],time_range[100];
char temid[11];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s%d",pt[i].id,&pt[i].age);
if(pt[i].age>=60){
age_r[a]=i;
a++;
}
else{
time_range[b]=i;
b++;
}
}
for(i=1;i<a-1;i++){
for(j=0;j<a-i;j++){
if(pt[age_r[j]].age<pt[age_r[j+1]].age){ //?????????????? ???debug?????????
strcpy(temid,pt[age_r[j]].id);
strcpy(pt[age_r[j]].id,pt[age_r[j+1]].id);
strcpy(pt[age_r[j+1]].id,temid);
tem=pt[age_r[j]].age;
pt[age_r[j]].age=pt[age_r[j+1]].age;
pt[age_r[j+1]].age=tem;
}
}
}
for(i=0;i<a;i++){
printf("%s\n",pt[age_r[i]].id);
}
for(i=0;i<b;i++){
printf("%s\n",pt[time_range[i]].id);
}
return 0;
}
| 9 |
4,021 |
int main (){
int a[100],e[100],f[100];
char c[100][100],b[100][100],d[100][100],x[100];
int n,p=-1,q=-1,k,z,i;
scanf("%d",&n);
for (i=0;i<n;i++){
scanf("%s %d",c[i],&a[i]);
if(a[i]>=60){
p++;
e[p]=a[i];
strcpy(b[p],c[i]);
}
if(a[i]<60){
q++;
f[q]=a[i];
strcpy(d[q],c[i]);
}
}
for (k=1;k<=p+1;k++){
for (i=0;i<p+1-k;i++){
if(e[i]<e[i+1]){
z=e[i];
e[i]=e[i+1];
e[i+1]=z;
strcpy( x,b[i]);
strcpy( b[i],b[i+1]);
strcpy( b[i+1],x);
}
}
}
for(i=0;i<=p;i++){
printf("%s\n",b[i]);
}
for(i=0;i<=q;i++){
printf("%s\n",d[i]);
}
return 0;
} | 9 |
4,022 | int main(){
int sz[100],aged[100];
char num[100][11],anum[100][11],q[100][11];
int n,i,k,j=0,s,p,e=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s",num[i]);
scanf("%d",&sz[i]);
}for(i=0;i<n;i++){
if(sz[i]>=60){
aged[j]=sz[i];
strcpy(anum[j],num[i]);
j++;
}
}for(s=1;s<j;s++){
for(k=0;k<j-s;k++){
if(aged[k]<aged[k+1]){
e=aged[k+1];
aged[k+1]=aged[k];
aged[k]=e;
strcpy(q[k],anum[k+1]);
strcpy(anum[k+1],anum[k]);
strcpy(anum[k],q[k]);
}
}
}for(p=0;p<j;p++){
printf("%s\n",anum[p]);
}for(i=0;i<n;i++){
if(sz[i]<60){
printf("%s\n",num[i]);
}
}return 0;
} | 9 |
4,023 |
void main()
{
struct person
{
char id[10];
int age;
} m[100],b[100];
int n,t,i,j;
char temp[10];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s",m[i].id);
strcpy(b[i].id,m[i].id);
scanf("%d",&m[i].age);
b[i].age=m[i].age;
}
for(i=0;i<n-1;i++)
for(j=0;j<n-1-i;j++)
{
if(m[j].age<m[j+1].age)
{
t=m[j].age;
m[j].age=m[j+1].age;
m[j+1].age=t;
strcpy(temp,m[j].id);
strcpy(m[j].id,m[j+1].id);
strcpy(m[j+1].id,temp);
}
}
for(i=0;i<n;i++)
if(m[i].age>=60) printf("%s\n",m[i].id);
for(i=0;i<n;i++)
if(b[i].age<60) printf("%s\n",b[i].id);
}
| 9 |
4,024 |
void main()
{
int n;
int a[105];
char c[105][11];
int i,j;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%s%d",c[i],&a[i]);
int aa[105]={0};
int num[105];
int u=0;
for(i=0;i<n;i++)
if(a[i]>=60)
{
aa[i]=a[i];
num[u]=i;
u++;
}
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
{
if(aa[i]>0&&aa[i]==aa[j])
aa[i]=0;
}
for(i=n;i>0;i--)
{
for(j=0;j<i;j++)
{
if(aa[j]<aa[j+1])
{
int t=aa[j];
aa[j]=aa[j+1];
aa[j+1]=t;
/* char tt[11];
strcpy(tt,c[i]);
strcpy(c[i],c[i+1]);
strcpy(c[i+1],tt);*/
}
}
}
for(i=0;aa[i]!=0;i++)
{
for(j=0;j<n;j++)
{
if(a[j]==aa[i])
{
printf("%s\n",c[j]);
}
}
}
int tem=0;
for(j=0;j<n;j++)
{
for(i=0;i<u;i++)
{
if(j==num[i])
tem=1;
}
if(tem==0)
printf("%s\n",c[j]);
tem=0;
}
} | 9 |
4,025 | struct patient
{
char id[10];
int age;
struct patient * next;
};
int main()
{
int n,i;
struct patient *p,*pre,*pnew,*head1,*head2;
head1=NULL;
head2=NULL;
scanf("%d\n",&n);
p=(struct patient *)malloc(sizeof(struct patient));
for(i=0;i<n;i++)
{
pnew=(struct patient *)malloc(sizeof(struct patient));
scanf("%s %d\n",pnew->id,&pnew->age);
pnew->next=NULL;
if(pnew->age>=60)
{
if(head1==NULL)
{
head1=pnew;
}
else
{
p=head1;
while(p&&p->age>=pnew->age)
{
pre=p;
p=p->next;
}
if(p==head1)
{
pnew->next=head1;
head1=pnew;
}
else
{
pre->next=pnew;
pnew->next=p;
}
}
}
else
{
if(head2==NULL)
{
head2=pnew;
}
else
{
p=head2;
while(p)
{
pre=p;
p=p->next;
}
if(p==head2)
{
pnew->next=head2;
head2=pnew;
}
else
{
pre->next=pnew;
pnew->next=p;
}
}
}
}
p=head1;
if(head1!=NULL)
{
while(p)
{
printf("%s\n",p->id);
p=p->next;
}
}
p=head2;
if(head2!=NULL)
{
while(p)
{
printf("%s\n",p->id);
p=p->next;
}
}
return 0;
} | 9 |
4,026 | struct stu
{
char name[20];
int age;
int order;
struct stu *next;
};
int main()
{
struct stu *p,*q,*t,*r,*head;
int n,i,j;
scanf("%d",&n);
head=(struct stu *)malloc(l);
q=head;
for(i=0;i<n;i++)
{
p=(struct stu *)malloc(l);
scanf("%s %d",p->name,&p->age);
p->order=i;
q->next=p;
q=p;
}
q->next=NULL;
for(i=0;i<n-1;i++)
for(p=head,j=0;j<n-1-i;j++,p=p->next)
{
q=p->next;
t=q->next;
if((q->age==t->age&&q->order>t->order)||(q->age<60&&t->age<q->age&&q->order>t->order)||(t->age<60&&t->age>q->age&&q->order>t->order)||(t->age>=60&&t->age>q->age))
{
r=t->next;
t->next=q;
p->next=t;
q->next=r;
}
}
p=head->next;
while(p!=NULL)
{
printf("%s\n",p->name);
p=p->next;
}
}
| 9 |
4,027 |
struct patient{
char A[10];
int age;
};
int main(){
int i,n,k,max,count;
struct patient inter;
struct patient *p;
scanf("%d",&n);
struct patient *sick=(struct patient*)malloc(sizeof(struct patient)*n);//??
struct patient *waitlist=(struct patient*)malloc(sizeof(struct patient)*n);//??
count=0;//????
for(i=0;i<n;i++){
scanf("%s %d",sick[i].A,&sick[i].age);
}//??
p=waitlist;
for (i=0;i<n;i++)
{
if (sick[i].age>=60)
{
*p=sick[i];
p++;
count++;
}
}//????
for (i=0;i<n;i++)
{
if (sick[i].age<60)
{
*p=sick[i];
p++;
}
}//?????
for (i=1;i<count;i++)
{
for (k=0;k<count-i;k++)
{
if (waitlist[k].age<waitlist[k+1].age)
{
inter=waitlist[k+1];
waitlist[k+1]=waitlist[k];
waitlist[k]=inter;
}
}
}//????
for (i=0;i<n;i++)
{
printf("%s\n",waitlist[i].A);
}
return 0;
} | 9 |
4,028 | struct patient
{
char name[10];
int age;
}p[100],e,old[100],young[100];
int main()
{
int n,i,j=0,k=0,o=-1,y=-1;
scanf("%d",&n);
struct patient p[100],old[100],young[100];
for(i=0;i<n;i++){
scanf("%s %d",p[i].name,&p[i].age);
if((p[i].age)>=60){
o++;
old[j]=p[i];
j++;
}else{
y++;
young[k]=p[i];
k++;
}
}//?????
for(i=120;i>=60;i--){
for(j=0;j<o+1;j++){
if(old[j].age==i){
printf("%s\n",old[j].name);
}
}
}//?????????? ? ??????????????
for(i=0;i<y+1;i++){
printf("%s\n",young[i].name);
}
return 0;
} | 9 |
4,029 | int main()
{
struct date
{
char a[10];
int num;
struct date *next;
};
struct date *p1,*p2,*head;
int n,i,temp,j,compare;
char tem[10];
scanf("%d",&n);
head=p1=p2=(struct date *)malloc(len);
scanf("%s %d",head->a,&head->num);
head->next=NULL;
head=p1;
for(i=2;i<=n;i++)
{
p2=(struct date *)malloc(len);
scanf("%s %d",p2->a,&p2->num);
p2->next=NULL;
p1->next=p2;
p1=p2;
}
for(i=n-1;i>=1;i--)
{
p1=head;p2=p1->next;
for(j=1;j<=i;j++)
{
compare=strcmp(p1->a,p2->a);
if(p1->num<60&&p2->num>=60)
{
strcpy(tem,p1->a);
strcpy(p1->a,p2->a);
strcpy(p2->a,tem);
temp=p2->num;
p2->num=p1->num;
p1->num=temp;
}
if(p1->num>=60&&p2->num>=60&&p1->num<p2->num)
{
strcpy(tem,p1->a);
strcpy(p1->a,p2->a);
strcpy(p2->a,tem);
temp=p2->num;
p2->num=p1->num;
p1->num=temp;
}
p1=p2;
p2=p1->next;
}
}
p1=p2=head;
for(i=1;i<=n;i++)
{
printf("%s\n",p2->a);
p1=p2;
p2=p1->next;
}
return 0;
} | 9 |
4,030 |
struct point{
char id[10];
int age;
}old[100],small[100];
int main(){
int n,i,j,o=0,s=0,t,m;
// char x[10];
scanf("%d",&n);
for(i=0;i<n;i++){
char x[10]={'\0'};
t=0;
scanf("%s %d",x,&t);
if(t>=60){
strcpy(old[o].id,x);
old[o].age=t;
o++;
}else{
strcpy(small[s].id,x);
small[s].age=t;
s++;
}
}
char p[10];
for(i=0;i<o;i++){
for(j=1;j<o-i;j++){
if(old[i].age>=old[i+j].age){
m=old[i+j].age;
old[i+j].age=old[i].age;
old[i].age=m;
strcpy(p,old[i+j].id);
strcpy(old[i+j].id,old[i].id);
strcpy(old[i].id,p);
}
}
}
for(i=o-1;i>=0;i--){
printf("%s\n",old[i].id);
}
for(i=0;i<s;i++){
printf("%s\n",small[i].id);
}
}
| 9 |
4,031 | struct pa
{
char id[10];
int age;
}patient[100],patient2[100];
void main()
{
int i,k,m,n,j,temp;
char id2[10];
scanf("%d\n",&n); //input the patient number
for(i=0;i<n;i++) //insert the information of the patients
{
scanf("%s %d\n",patient[i].id,&patient[i].age);
}
for(i=0,j=0;i<n;) //deal with the information
{
if(patient[i].age>=60)
{
strcpy(patient2[j].id,patient[i].id);
patient2[j].age=patient[i].age;
// printf("%d ",patient2[j].age);
j++;
for(k=i;k<n-1;k++)
{
strcpy(patient[k].id,patient[k+1].id);
patient[k].age=patient[k+1].age;
}
n--;
}
else i++;
}
// printf("\n");
// printf("%d",j);
for(i=1;i<j;i++)
{
for(k=0;k<i;k++)
{
if(patient2[i].age>patient2[k].age)
{
temp=patient2[i].age;
strcpy(id2,patient2[i].id);
for(m=i;m>k;m--)
{
patient2[m].age=patient2[m-1].age;
strcpy(patient2[m].id,patient2[m-1].id);
}
patient2[k].age=temp;
strcpy(patient2[k].id,id2);
}
// printf("\n");
// printf("%d %d ",patient2[i].age,patient2[i+1].age);
}
}
for(i=0;i<j;i++)printf("%s\n",patient2[i].id);
for(i=0;i<n;i++)printf("%s\n",patient[i].id);
} | 9 |
4,032 | main()
{
struct p
{char num[100];
int age;
} p[101];
int n,i,j,k,m=0;
scanf("%d",&n);
for(i=1;i<=n;i++) scanf("%s %d",&p[i].num,&p[i].age);
struct q
{char num[100];
int age;
} q[101];
for(i=1,j=1;i<=n;i++) {if(p[i].age>=60) {strcpy(q[j].num,p[i].num);q[j].age=p[i].age;j++;m=m+1;}}
for(j=1;j<=m;j++)
{
for(i=1;i<=m-1;i++)
{
if(q[i].age<q[i+1].age)
{
q[101]=q[i];
q[i]=q[i+1];
q[i+1]=q[101];
}
}
}
printf("%s",q[1].num);
for(i=2;i<=m;i++) printf("\n%s",q[i].num);
for(i=1;i<=n;i++) if(p[i].age<60) printf("\n%s",p[i].num);
}
| 9 |
4,033 | main()
{ char temp_0[10],id[100][10];
int i,j,n,max,age[100],num[100],yes[100],ncount=1,temp,num_1;
scanf("%d",&n);
for(i=0;i<n;i++)
{num[i]=i;
scanf("%s %d",id[i],&age[i]);
}
for(j=0;j<n;j++) {
for(i=0;i<n-j-1;i++)
{ if(age[i]<age[i+1])
{ strcpy(temp_0,id[i]);
temp=age[i];
num_1=num[i];
strcpy(id[i],id[i+1]);
age[i]=age[i+1];
num[i]=num[i+1];
age[i+1]=temp;
strcpy(id[i+1],temp_0);
num[i+1]=num_1; }
}}
for(i=0;i<n;i++)
{if(age[i]>=60)
printf("%s\n",id[i]);
}
for(j=0;j<n;j++)
{for(i=0;i<n-j-1;i++)
{if(num[i]>num[i+1])
{ strcpy(temp_0,id[i]);
temp=age[i];
num_1=num[i];
strcpy(id[i],id[i+1]);
age[i]=age[i+1];
num[i]=num[i+1];
age[i+1]=temp;
strcpy(id[i+1],temp_0);
num[i+1]=num_1;
}}
}
for(i=0;i<n;i++)
{if(age[i]<60)
printf("%s\n",id[i]);}
getchar();
getchar(); }
| 9 |
4,034 |
struct patient
{
char name[20];
int age;
} line[202], temp;
int main()
{
int n, i, j;
scanf("%d", &n);
for(i=1;i<=n;i++)
{
scanf("%s", &line[i].name);
scanf("%d", &line[i].age);
}
for(i=1;i<=n;i++)
{
for (j=n;j>i;j--)
{
if(line[j].age>=60){
if(line[j].age>line[j-1].age)
{
temp=line[j];
line[j]=line[j-1];
line[j-1]=temp;
}
}
}
}
for(i=1;i<=n;i++)
{
printf("%s\n", line[i].name);
}
return 0;
} | 9 |
4,035 | main()
{
char senior[100][10];
char junior[100][10];
char temp[10];
int list[100]={0};
int se[100];
int ju[100];
int n,i,j,k,nums,numj,year;
scanf("%d",&n);
nums=-1; numj=-1;
for (i=1;i<=n;i++)
{
scanf("%s",temp);
scanf("%d",&year);
if (year>=60)
{
nums++;
strcpy(senior[nums],temp);
se[nums]=year;
list[nums]=nums;
}
else
{
numj++;
strcpy(junior[numj],temp);
ju[numj]=year;
}
}
for (i=0;i<nums;i++)
for (j=i+1;j<=nums;j++)
if ((se[i]<se[j]))
{
year=se[i]; se[i]=se[j]; se[j]=year;
year=list[i]; list[i]=list[j]; list[j]=year;
strcpy(temp,senior[i]);
strcpy(senior[i],senior[j]);
strcpy(senior[j],temp);
}
else if (se[i]==se[j] && list[i]>list[j])
{
year=se[i]; se[i]=se[j]; se[j]=year;
year=list[i]; list[i]=list[j]; list[j]=year;
strcpy(temp,senior[i]);
strcpy(senior[i],senior[j]);
strcpy(senior[j],temp);
}
// for (i=0;i<numj;i++)
// for (j=i+1;j<=numj;j++)
// if (strcmp(junior[i],junior[j])>0)
// {
// year= ju[i]; ju[i]=ju[j]; ju[j]=year;
// strcpy(temp,junior[i]);
// strcpy(junior[i],junior[j]);
// strcpy(junior[j],temp);
// }
for (i=0;i<=nums;i++)
{
//printf("%d ",list[i]);
puts(senior[i]);
}
for (i=0;i<=numj;i++)
puts(junior[i]);
return 0;
}
| 9 |
4,036 | struct patient
{
int age;
char id[12];
};
void swap(struct patient *a,struct patient *b)
{
struct patient tmp;
tmp = *a;
*a = *b;
*b = tmp;
}
int main()
{
int n,i,j=0,k=0,l;
scanf("%d",&n);
struct patient tmp;
struct patient young[120];
struct patient old[120];
for (i=0; i<n; i++)
{
scanf("%s",tmp.id);
scanf("%d",&tmp.age);
if( tmp.age >= 60 )
old[j++] = tmp;
else
young[k++] = tmp;
}
for(i=0; i<j; i++)
{
for(l=0; l<j-i-1; l++)
{
if( old[l].age < old[l+1].age )
swap(&old[l],&old[l+1]);
}
}
for(i=0; i<j; i++)
printf("%s\n",old[i].id);
for(i=0; i<k; i++)
printf("%s\n",young[i].id);
return 0;
}
| 9 |
4,037 | struct rat
{
char num[11];
int age;
struct rat *next;
};
int n;
struct rat *creat(void)
{
struct rat *head,*p1,*p2;
int i;
p1=p2=(struct rat*)malloc(LEN);
head=p1;
scanf("%s%d",p1->num,&p1->age);
for(i=2;i<=n;i++)
{
p2->next=p1;
p2=p1;
p1=(struct rat*)malloc(LEN);
scanf("%s%d",p1->num,&p1->age);
}
p2->next=p1;
p1->next=NULL;
return(head);
}
struct rat *sort(struct rat *head,int count)
{
struct rat *p1,*p2,*p3,*temp;
int i,j;
for(j=1;j<=count-1;j++)
{
p1=head;
p2=p1->next;
p3=p2;
for(i=0;i<count-j;i++)
{
if(p1->age<p2->age)
{
temp=p2->next;
p2->next=p1;
p1->next=temp;
if(i==0)
{
head=p2;
p2=temp;
}
else
{
p3->next=p2;
p3=p2;
p2=temp;
}
}
else
{
if(i==0)
{
p3=head=p1;
p1=p1->next;
p2=p2->next;
}
else
{
p1=p1->next;
p2=p2->next;
p3=p3->next;
}
}
}
}
return(head);
}
struct rat *del(struct rat *head,int t)
{
struct rat *p1,*p2;
int i;
p1=head;
for(i=1;i<=t;i++)
{
if(p1->age<60)
{
if(i==1)
head=p1;
p2=p1;
p1=p1->next;
continue;
}
if(p1->age>=60)
{
if(i==1)
{
head=p1->next;
break;
}
p2->next=p1->next;
break;
}
}
return(head);
}
void main()
{
struct rat *head,*p1,*s,*p2,*p3;
int i,count=0,t;
scanf("%d",&n);
t=n;
head=creat();
p1=head;
p3=p2=(struct rat*)malloc(LEN);
for(i=1;i<=n;i++)
{
if(p1->age>=60)
{
if(count==0)
s=p2;
p2->age=p1->age;
strcpy(p2->num,p1->num);
p3->next=p2;
p3=p2;
p2=(struct rat*)malloc(LEN);
count++;
}
p1=p1->next;
}
s=sort(s,count);
for(i=1;i<=count;i++)
{
head=del(head,t);
t=t-1;
}
p1=s;
for(i=1;i<=count;i++)
{
printf("%s\n",p1->num);
p1=p1->next;
}
p1=head;
for(i=1;i<=(n-count);i++)
{
printf("%s\n",p1->num);
p1=p1->next;
}
}
| 9 |
4,038 | int main()
{
struct pa
{
char id[10];
int age;
}pat[100],p1[100],p2[100],temp;
int i,n,j=0,k=0,m;
cin>>n;
for(i=0;i<n;i++)
{
cin>>pat[i].id>>pat[i].age;
}
for(i=0;i<n;i++)
{
if(pat[i].age>=60)
{
p1[j]=pat[i];
j++;
}
else
{
p2[k]=pat[i];
k++;
}
}
for(i=j-1;i>0;i--)
{
for(m=0;m<i;m++)
{
if(p1[m].age<p1[m+1].age)
{
temp=p1[m];
p1[m]=p1[m+1];
p1[m+1]=temp;
}
}
}
for(i=0;i<j;i++)
{
printf("%s\n",p1[i].id);
}
for(i=0;i<k;i++)
{
printf("%s\n",p2[i].id);
}
return 0;
} | 9 |
4,039 | int main(){
int n,i,j,b;
struct{
char hao[10];
int ni;
int pa;
}dk[100],t,p;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s %d",&(dk[i].hao),&(dk[i].ni));
}
for(i=0;i<n-1;i++){
for(j=0;j<n-i-1;j++){
if((dk[j].ni<60)&&(dk[j+1].ni>=60)){
t=dk[j];
dk[j]=dk[j+1];
dk[j+1]=t;
}
}
}
for(i=0;i<n-1;i++){
for(j=0;j<n-1-i;j++){
if((dk[j+1].ni>=60)&&(dk[j].ni>=60)&&(dk[j].ni<dk[j+1].ni)){
p=dk[j];
dk[j]=dk[j+1];
dk[j+1]=p;
}
}
}
b=strlen(dk[0].hao);
for(i=0;i<n;i++){
for(j=0;j<b;j++){
printf("%c",dk[i].hao[j]);
}
printf("\n");
}
return 0;
}
| 9 |
4,040 | struct patient
{ char id[11];
int age,seq;
struct patient *next;
};
main()
{ int n,n1=0,n2=0,i,j,m,at;
char id[10];
struct patient *head1,*head2,*p11,*p12,*p21,*p22,*t,*q;
scanf("%d",&n);
head1=NULL;
head2=NULL;
for(i=0;i<n;i++)
{
scanf("%s%d",id,&at);
if(at>=60)
{ if(head1==NULL)
{
head1=(struct patient*)malloc(sizeof(struct patient));
strcpy(head1->id,id);
head1->age=at;
head1->next=NULL;
}
else
{ p11=(struct patient *)malloc(sizeof(struct patient));
p11->age=at;
strcpy(p11->id,id);
for(t=head1,q=t;t!=NULL;q=t,t=t->next)
{ if(t->age<at&&t!=head1)
{
q->next=p11;
p11->next=t;
break;
}
if(t->age<at&&t==head1)
{
p11->next=head1;
head1=p11;
break;
}
}
if(t==NULL)
{
q->next=p11;
p11->next=NULL;
}
}
}
if(at<60)
{ if(head2==NULL)
{
head2=(struct patient*)malloc(sizeof(struct patient));
strcpy(head2->id,id);
head2->age=at;
head2->next=NULL;
p22=head2;
}
else
{
p21=(struct patient *)malloc(sizeof(struct patient));
p21->age=at;
strcpy(p21->id,id);
p22->next=p21;
p21->next=NULL;
p22=p21;
}
}
}
for(t=head1,q=t;t!=NULL;q=t,t=t->next);
q->next=head2;
for(t=head1;t->next!=NULL;t=t->next)
printf("%s\n",t->id);
printf("%s",t->id);
} | 9 |
4,041 | void main()
{
struct pa
{ char m[10];
int a;
};
struct pa p[100],t,s={"0",0},pp[100];
int n,i,j=0,m=0,k;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%s%d",&p[i].m,&p[i].a);
for(i=0;i<n;i++)
{if(p[i].a>=60)m++;}
for(j=0;j<m;j++)
{t=s;k=100;
for(i=0;i<n;i++)
{if(p[i].a>=60&&p[i].a>t.a){t=p[i];k=i;}}
pp[j]=t;p[k]=s;
}
for(i=0;i<n;i++)
if(p[i].a<60&&p[i].a>0){pp[j]=p[i];j++;}
for(i=0;i<n;i++)
printf("%s\n",pp[i].m);
} | 9 |
4,042 | void main()
{
int n;
int i;
int j;
struct client
{
char num[11];
int age;
};
struct client line[100];
struct client temp;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%s%d",&line[i].num,&line[i].age);
for(i=0;i<n-1;i++)
for(j=0;j<n-1;j++)
{
if(line[j].age>=60&&line[j+1].age>=60)
{
if(line[j].age<line[j+1].age)
{
temp=line[j];
line[j]=line[j+1];
line[j+1]=temp;
}
}
if(line[j].age<60 && line[j+1].age>=60)
{
temp=line[j];
line[j]=line[j+1];
line[j+1]=temp;
}
}
for(i=0;i<n;i++)
printf("%s\n",line[i].num);
} | 9 |
4,043 | int main()
{
int c,d,e,f,n,i;
char a[100][10];
int b[100];
scanf ("%d",&n);
for (i=0;i<n;i++)
{
scanf ("%s %d",a[i],&b[i]);
}
for (c=0;c<n;c++)
{
e=-1;
for (i=0;i<n;i++)
{
if (b[i]>=60)
{
if (b[i]>e)
{
e=b[i];
f=i;
}
}
}
if(e!=-1)
{
printf ("%s\n",a[f]);
b[f]=0;
}
}
for (i=0;i<n;i++)
{
if (b[i]!=0)
{
printf ("%s\n",a[i]);
}
}
getchar();
getchar();
}
| 9 |
4,044 | struct mouse
{
char id[10];
int age;
struct mouse *next;
};
struct mouse *creat(int n)
{
struct mouse *head,*p1,*p2;
int i;
for(i=0;i<n;i++)
{
if(i==1) head=p1;
if(i>1) p2->next=p1;
p2=p1;
p1=(struct mouse *)malloc(sizeof(struct mouse));
scanf("%s %d",p1->id,&p1->age);
}
p2->next=p1;p1->next=NULL;
return(head);
}
struct mouse *order(struct mouse *head,int n)
{
struct mouse *p1,*p2;
int i,j,x;
char a[10];
for(i=1;i<n;i++)
{
p2=head;p1=p2->next;
for(j=0;j<n-i;j++)
{
if(p2->age<p1->age&&p1->age>=60)
{
x=p2->age;p2->age=p1->age;p1->age=x;
strcpy(a,p2->id);strcpy(p2->id,p1->id);strcpy(p1->id,a);
}
p2=p1;p1=p1->next;
}
}
return(head);
}
main()
{
struct mouse *head,*p;
int i,n;
scanf("%d",&n);
head=creat(n);
head=order(head,n);
p=head;
for(i=0;i<n;i++)
{
printf("%s\n",p->id);
p=p->next;
}
}
| 9 |
4,045 | int N;
struct patient
{
char ID[20];
int age;
struct patient*next;
};
struct patient*creat()
{
struct patient*head,*p1,*p2;
int i;
p1=(struct patient*)malloc(LEN);
scanf("%s %d",p1->ID,&p1->age);
p1->next=NULL;
head=p1;
p2=p1;
for(i=1;i<N;i++)
{
p1=(struct patient*)malloc(LEN);
scanf("%s %d",p1->ID,&p1->age);
p1->next=NULL;
p2->next=p1;
p2=p1;
}
return(head);
}
struct patient*rank(struct patient*head)
{
int i,j,a;
char ID[20];
struct patient*p1,*p2;
for(i=0;i<N-1;i++)
{
p1=head;
p2=head->next;
for(j=0;j<N-i-1;j++)
{
if((p1->age<p2->age)&&(p2->age>=60))
{
a=p1->age;
p1->age=p2->age;
p2->age=a;
strcpy(ID,p1->ID);
strcpy(p1->ID,p2->ID);
strcpy(p2->ID,ID);
}
p1=p2;
p2=p2->next;
}
}
return(head);
}
void print(struct patient*head)
{
struct patient*p;
p=head;
while(p)
{
printf("%s\n",p->ID);
p=p->next;
}
}
int main()
{
struct patient*head;
scanf("%d",&N);
head=creat();
head=rank(head);
print(head);
}
| 9 |
4,046 |
int main()
{
int i,j,k,n;
char a[11];
int b;
scanf("%d",&n);
struct patient
{
char num[11];
int age;
}pat[100];
for(i=0;i<n;i++){
scanf("%s%d",pat[i].num,&pat[i].age);
}
for(i=0;i<n;i++){
for(j=0;j<n-1-i;j++){
if(pat[j].age<pat[j+1].age&&pat[j+1].age>=60){
for(k=0;k<10;k++){
a[k]=pat[j].num[k];
pat[j].num[k]=pat[j+1].num[k];
pat[j+1].num[k]=a[k];
}
b=pat[j].age;
pat[j].age=pat[j+1].age;
pat[j+1].age=b;
}
}
}
for(i=0;i<n;i++){
printf("%s\n",pat[i].num);
}
return 0;
} | 9 |
4,047 | struct patient{
char name[11];
int age;
int order;
};
int main(){
struct patient peo[NO];
int n,i,count=0,COUNT,j,k,e,agedata[NO],a=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s",&peo[i].name);
scanf("%d",&peo[i].age);
}
for(i=0;i<n;i++){
if(peo[i].age>=60){
count++;
agedata[a]=peo[i].age;
a++;
}
}//count number of old people
COUNT=count;
for(i=0;i<n;i++){
if(peo[i].age<60){
peo[i].order=count;
count++;
}
}// record order for young people
for(k=1;k<COUNT;k++){
for(j=0;j<COUNT-k;j++){
if(agedata[j]<agedata[j+1]){
e=agedata[j+1];
agedata[j+1]=agedata[j];
agedata[j]=e;
}
}
}//rearrage age of old people
for(i=0;i<COUNT;i++){
for(j=0;j<n;j++){
if(peo[j].age==agedata[i]){
peo[j].order=i;
}
}
}// record order for old people
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(peo[j].order==i){
printf("%s\n",peo[j].name);
}
}
}
return 0;
} | 9 |
4,048 | struct person
{
char c[10];
int a;
struct person *next;
};
int main()
{
int i,n;
struct person *head,*p1,*p2,*p,*p0,*p3;
scanf("%d",&n);
i=0;
head=NULL;
while(i<n)
{
p1=(struct person*)malloc(len);
scanf("%s %d",p1->c,&p1->a);
if(i==0) { head=p1;p2=p1;}
else
{
p2->next=p1;
p2=p1;
}
i++;
}
p2->next=NULL;
for(i=0;i<n;i++)
{
p=p0=head;
while(p!=NULL)
{
if(p->a>p0->a) p0=p;
p=p->next;
}
if(p0->a>=60)
{
printf("%s\n",p0->c);
p=head;
while(p->a!=p0->a)
{
p3=p;
p=p->next;
}
if(p==head) head=p->next;
else p3->next=p->next;
}
else
{
printf("%s\n",head->c);
head=head->next;
}
}
}
| 9 |
4,049 | struct patient
{
char ID[11];
int age;
struct patient *next;
}
main()
{
int i,n;
struct patient *old,*young,*ot,*yt,*p;
struct patient *paixu(struct patient* h);
scanf("%d", &n);
ot=NULL;
yt=NULL;
for(i=0;i<n;i++)
{
p=(struct patient *)malloc(len);
scanf("%s %d",p->ID,&p->age);
p->next=NULL;
if (p->age<60)
{
if (yt)
yt->next=p;
else
young=p;
yt=p;
}
else
{
if(ot)
ot->next=p;
else
old=p;
ot=p;
}
}
old=paixu(old);
while(old)
{
printf("%s\n",old->ID);
old=old->next;
}
while(young)
{
printf("%s\n",young->ID);
young=young->next;
}
}
struct patient *paixu(struct patient* h)
{
struct patient* hh=h,*before,*after;
h=h->next;
hh->next=NULL;
while(h)
{
before=hh;
if(before->age<h->age)
{
hh=h;
after=h->next;
h->next=before;
h=after;
}
else
{
while (before->next)
{
if(before->next->age>=h->age)
before=before->next;
else
break;
}
after=h->next;
h->next=before->next;
before->next=h;
h=after;
}
}
return hh;
}
| 9 |
4,050 | struct patient
{
char id[11];
int age;
} pat[100];
int main()
{
int n,i;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s %d", pat[i].id, &pat[i].age);
}
int temp=0;
struct patient e;
for(i=0;i<n;i++){
if(pat[i].age>=60){
e=pat[i];
int j;
for(j=i;j>=temp+1;j--){
pat[j]=pat[j-1];
}
pat[temp]=e;
temp++;
}
}
int k;
for(k=1;k<=temp;k++){
for(i=0;i<temp-k;i++){
if(pat[i].age<pat[i+1].age){
e=pat[i];
pat[i]=pat[i+1];
pat[i+1]=e;
}
}
}
for(i=0;i<n;i++){
printf("%s\n",pat[i].id);
}
return 0;
}
| 9 |
4,051 |
struct student
{
char num[200];
int sum;
struct student *next;
};
void main()
{
int n,i;
struct student *p1,*p2,*p3,*head;
scanf("%d",&n);
for (i=0;i<n;i++)
{
p2=(struct student*)malloc(sizeof(struct student));
if(i==0)
{head=p2;p3=head;}
scanf("%s %d",p2->num,&p2->sum);
p2->next=NULL;
if(p2->sum>=60){
if(i==1){
if(head->sum>=p2->sum){
head->next=p2;
p2->next=NULL;p3=p2;
}
else{p1=head;
p2->next=head;
head=p2;
}
}
if(i>1){
for(p1=head;p1->next!=NULL;p1=p1->next){
if(p1->sum>=p2->sum&&(p1->next->sum)<p2->sum){
p2->next=p1->next;
p1->next=p2;
break;
}
}
if(p2->next==NULL){
if(p2->sum>head->sum){
p2->next=head;
head=p2;
}
if(p2->sum<p1->sum){
p2->next=NULL;p3=p2;
p1->next=p2;
}
}
}
}
else{
if(i!=0){
p2->next=NULL;
p3->next=p2;p3=p2;}
}
}
p1=head;
for (i=0;(i<n&&p1!=NULL);i++)
{
printf("%s\n",p1->num);
p1=p1->next;
}
} | 9 |
4,052 | void main()
{
struct p
{
int k;
char id[10];
int age;
}pa[100]={0,"",0},pb[100]={0,"",0},temp;
int n;
int i,j,k,age,na,nb;
char id[10]={""};
scanf("%d",&n);
for(i=0,j=0;i+j<n;)
{
scanf("%s%d",&id,&age);
if(age>=60)
{
pa[i].age=age;
strcpy(pa[i].id,id);
pa[i].k=i;
i++;
}
else
{
pb[j].age=age;
strcpy(pb[j].id,id);
pb[j].k=j;
j++;
}
}
na=i;nb=j;
for(j=1;j<=n-1;j++)
{
for(i=0;i<n-j;i++)
{
if(pa[i].age < pa[i+1].age)
{
temp.age=pa[i+1].age;strcpy(temp.id,pa[i+1].id);
pa[i+1].age=pa[i].age;strcpy(pa[i+1].id,pa[i].id);
pa[i].age=temp.age;strcpy(pa[i].id,temp.id);
}
}
}
printf("%s",pa[0].id);
for(i=1;i<=na;i++)
{
printf("\n%s",pa[i].id);
}
for(j=0;j<=nb;j++)
{
puts(pb[j].id);
}
} | 9 |
4,053 | struct patient
{
char id[20];
int age;
};
int main()
{
int i,n,j,max,num=0;
struct patient a[110],t;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%s%d",a[i].id,&a[i].age);
for(i=0;i<n;i++)
{
if(a[i].age>=60)
num++;
}
for(i=0;i<num;i++)
{
max=i;
for(j=i;j<n;j++)
{
if(a[j].age>a[max].age)
{
max=j;
}
}
t=a[max];
for(j=max;j>i;j--)
a[j]=a[j-1];
a[i]=t;
}
for(i=0;i<n;i++)
printf("%s\n",a[i].id);
return 0;
}
| 9 |
4,054 | void main()
{
struct people
{
char id[30];
int age;
}x[100],y[100],z;
int a,b,c,e,i,j=0,k=0,n;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s %d",x[k].id,&x[k].age);
if(x[k].age>=60)
{
y[j].age=x[k].age;
strcpy(y[j].id,x[k].id);
j=j+1;
k=k-1;
}
k=k+1;
}
for(i=0;i<j;i++)
for(k=0;k<j-i-1;k++)
if(y[k].age<y[k+1].age)
{z=y[k+1];
y[k+1]=y[k];
y[k]=z;
}
for(i=0;i<j;i++)
printf("%s\n",y[i].id);
for(i=0;i<n-j;i++)
printf("%s\n",x[i].id);
} | 9 |
4,055 | main()
{
int i,k,j,l,n,w,max,old;
int q=0;
char d[101][10];
int a[101];
int b[101];
int c[101];
scanf("%d",&n);
old=0;
for(i=1;i<=n;i++)
scanf("%s %d",d[i],&a[i]);
for(i=1;i<=n;i++)
{
b[i]=0;
if(a[i]>=60)
{
b[i]=1;
old=old+1;
}
}
for(i=1;i<=old;i++)
{
max=0;
for(j=1;j<=n;j++)
{
if(b[j]==1)
{
if(a[j]>max)
{
max=a[j];
w=j;
}
}
}
c[i]=w;
b[w]=2;
}
for(l=1;l<=old;l++)
{
q=c[l];
printf("%s\n",d[q]);
}
for(l=1;l<=n;l++)
{
if(b[l]==0)
printf("%s\n",d[l]);
}
getchar();
getchar();
getchar();
getchar();
}
| 9 |
4,056 | struct patient
{
char id[10];
int age;
}pa[100];
void main()
{
int n,i,j,max=59,m,t=0;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%s %d",pa[i].id,&pa[i].age);
for(i=0;i<n;i++)
if(pa[i].age>59)t++;
for(j=0;j<t;j++)
{
for(i=0;i<n;i++)
if(pa[i].age>max)
{
max=pa[i].age;
m=i;
}
printf("%s\n",pa[m].id);
pa[m].age=0;
max=59;
}
for(i=0;i<n;i++)
if(pa[i].age<=59&&pa[i].age!=0)
printf("%s\n",pa[i].id);
}
| 9 |
4,057 |
void main()
{
int n,i,j,k;
struct patient
{
char id[10];
int age;
}pa[1000],t;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s %d",pa[i].id,&pa[i].age);
}
for(i=0;i<n;i++)
{
for(j=n-1;j>=0;j--)
if(pa[j].age>pa[j-1].age&&pa[j].age>=60)
{
t=pa[j];
pa[j]=pa[j-1];
pa[j-1]=t;
}
}
for(i=0;i<n;i++)
{
if(pa[i].age>=60)
{
printf("%s\n",pa[i].id);
}
}
for(i=0;i<n;i++)
{
if(pa[i].age<60)
{
printf("%s\n",pa[i].id);
}
}
}
| 9 |
4,058 |
struct st
{
int age,he;
char num[15];
struct st *next;
};
struct st *creat(int n)
{
struct st *head,*p1,*p2;
int i,h=105;
p1=(struct st *)malloc(sizeof(struct st));
p2=p1;
head=p1;
for (i=1;i<=n;i++)
{
p1=(struct st *)malloc(sizeof(struct st));
scanf("%s %d",p1->num,&p1->age);
if (p1->age >= 60)
p1->he=p1->age*1000+h;
else p1->he=h;
p1->next=NULL;
p2->next=p1;
p2=p1;
h--;
}
return(head);
}
void paixu(struct st *head)
{
struct st *max,*p,*p1,*p2,*p3,*p4;
p1=head;
while(p1->next)
{
p2=p1->next;
max=p2;
p4=p2;
p=p2->next;
while(p)
{
if (p->he > max->he)
{
max=p;
p3=p4;
}
p=p->next;
p4=p4->next;
}
if (max>p1->next)
{
p3->next=max->next;
p1->next=max;
max->next=p2;
}
p1=p1->next;
}
}
void main()
{
struct st *creat(int n);
void paixu(struct st *head);
struct st *head,*p;
int n;
scanf("%d",&n);
head=creat(n);
paixu(head);
p=head->next;
while(p)
{
printf("%s\n",p->num);
p=p->next;
}
} | 9 |
4,059 | int main()
{
int n,i,j=0,k,l;
struct patient
{
char num[10];
int age;
}p[100],temp;
scanf("%d",&n);
for(i=0;i<n;i++)
{
do{scanf("%c",&p[i].num[j]);j++;}
while(p[i].num[j-1]!=' ');
p[i].num[j-1]='\0';
scanf("%d",&p[i].age);
j=0;
}
for(i=0;i<n;i++)
{
k=i;
for(j=i+1;j<n;j++)
if(p[j].age>p[k].age) k=j;
if(k!=i&&p[k].age>=60)
{
temp=p[k];
for(l=k;l>=i+1;l--)
{
p[l]=p[l-1];
}
p[i]=temp;
}
}
for(i=0;i<n;i++)
{
printf("%s",p[i].num);if(i!=n-1) printf("\n");
}
return 0;
} | 9 |
4,060 | void main()
{
int n;
int i,j=0,k;
int t;
int old[100];
int age[100];
char a[100][20];
char a1[100][20];
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%s",a[i]);
scanf("%s",a1[i]);
}
for(i=1;i<=n;i++)
{
age[i]=atoi(a1[i]);
if(age[i]>=60)
{
old[j]=i;
j++;
}
}
for(i=0;i<j;i++)
for(k=0;k<j-i-1;k++)
if(age[old[k]]<age[old[k+1]])
{
t=old[k];
old[k]=old[k+1];
old[k+1]=t;
}
for(i=0;i<j;i++)
printf("%s\n",a[old[i]]);
for(i=1;i<=n;i++)
{
if(age[i]>=60)
continue;
printf("%s\n",a[i]);
}
}
| 9 |
4,061 | void main()
{
int n,a[100],t,b[100],c[100];
char h[100][10],h1[100][10],h2[100][10],y[10];
scanf("%d",&n);
int i,j,k;
int i1,j1;
for(i=0;i<n;i++)
{
scanf("%s",h[i]);
scanf("%d",&a[i]);
}
i1=0;j1=0;
for(k=0;k<n;k++)
{
if(a[k]>=60)
{b[i1]=a[k];
strcpy(h1[i1],h[k]);i1++;}
else
{c[j1]=a[k];
strcpy(h2[j1],h[k]);j1++;}
}
for(j=0;j<i1-1;j++)
for(i=0;i<i1-1-j;i++)
if(b[i]<b[i+1])
{
t=b[i];
b[i]=b[i+1];
b[i+1]=t;
strcpy(y,h1[i]);
strcpy(h1[i],h1[i+1]);
strcpy(h1[i+1],y);
}
for(i=0;i<i1;i++)
{
puts(h1[i]);
}
for(i=0;i<j1;i++)
puts(h2[i]);
}
| 9 |
4,062 | int main()
{
int n,i,j,y[200],p[200];
char a[100][11];
scanf("%d",&n);
for(i=0;i<200;i++)
{
p[i]=200-i;
}
for(i=0;i<n;i++)
{
scanf("%s %d",a[i],&y[i]);
}
for(i=0;i<=140;i++)
{
for(j=0;j<n;j++)
{
if(y[j]==p[i])
printf("%s\n",a[j]);
}
}
for(i=0;i<n;i++)
{
if(y[i]<60)
printf("%s\n",a[i]);
}
getchar();
getchar();
} | 9 |
4,063 | int i,j,n;
struct st
{
char a[20];
int x;
struct st *next;
}*p1,*p2,*p,*head,*pre;
void main()
{
scanf("%d",&n);void f(struct st *);
p1=p2=head=(struct st *)malloc(sizeof(struct st));
for(i=0;i<n;i++)
{
scanf("%s %d",p1->a,&p1->x);
p1=(struct st *)malloc(sizeof(struct st));p2->next=p1;p2=p1;
}
f(head);
p=head;
for(i=0;i<n;i++)
{
printf("%s\n",p->a);p=p->next;
}
}
void f(struct st *p)
{
for(i=0;i<n-1;i++)
{
pre=p1=p2=head;p1=p1->next;
for(j=0;j<n-1-i;j++)
{
if(p1->x>p2->x&&p1->x>=60)
{
if(j==0)
{p2->next=p1->next;p1->next=p2;head=pre=p1;}
else
{p2->next=p1->next;p1->next=p2;pre->next=p1;}
}
if(j!=0)pre=pre->next;
p2=pre->next;p1=p2->next;
}
}
}
| 9 |
4,064 | struct patient
{
char No[10];
int age;
}grp1[100],grp2[100],grp3[100];
int main()
{
int n;
scanf("%d",&n);
int i;
for(i=0;i<n;i++)
{
scanf("%s%d",&grp1[i].No,&grp1[i].age);
}
for(i=0;i<n;i++)
{
grp2[i].age=-1;
grp3[i].age=-1;
}
for(i=0;i<n;i++)
{
if(grp1[i].age>=60)
{
strcpy(grp2[i].No,grp1[i].No);
grp2[i].age=grp1[i].age;
}
if(grp1[i].age<60)
{
strcpy(grp3[i].No,grp1[i].No);
grp3[i].age=grp1[i].age;
}
}
char y[10];
int x;
int k,m;
for(k=1;k<n;k++)
{
for(m=0;m<n-k;m++)
{
if(grp2[m].age<grp2[m+1].age)
{
x=grp2[m+1].age;
grp2[m+1].age=grp2[m].age;
grp2[m].age=x;
strcpy(y,grp2[m+1].No);
strcpy(grp2[m+1].No,grp2[m].No);
strcpy(grp2[m].No,y);
}
}
}
for(i=0;i<n;i++)
{
if(grp2[i].age!=-1)
printf("%s\n",grp2[i].No);
}
for(i=0;i<n;i++)
{
if(grp3[i].age!=-1)
printf("%s\n",grp3[i].No);
}
return 0;
} | 9 |
4,065 | int main()
{
struct patient{char id[10];int a;}patients[100];
struct old{char ido[10];int ao;}olds[100];
struct young{char idy[10];int ay;}youngs[100];
int n,y=0,o=0,so=0,sy=0,e;
scanf("%d",&n);
char f[10];
for(int j=0;j<n;j++)
{
scanf("%s",patients[j].id);
scanf("%d",&patients[j].a);
if(patients[j].a<60)
{
strcpy(youngs[y].idy,patients[j].id);
youngs[y].ay=patients[j].a;
y++;
}
if(patients[j].a>=60)
{
strcpy(olds[o].ido,patients[j].id);
olds[o].ao=patients[j].a;
o++;
}
}
for(int r=o-1;r>0;r--)
{
for(int i=0;i<r;i++)
{
if(olds[i].ao<olds[i+1].ao)
{
e=olds[i+1].ao;
olds[i+1].ao=olds[i].ao;
olds[i].ao=e;
strcpy(f,olds[i+1].ido);
strcpy(olds[i+1].ido,olds[i].ido);
strcpy(olds[i].ido,f);
}
}
}
for(int l=0;l<=o-1;l++)
{
printf("%s\n",olds[l].ido);
}
for(int m=0;m<=y-1;m++)
{
printf("%s\n",youngs[m].idy);
}
return 0;
}
| 9 |
4,066 | int main()
{
struct point
{
char x[10];
int y;
}
sz[100];
struct po
{
char a[10];
int b;
int c;
}
lnr[100];
int n,temp;
int tag=0;
char tem[100];
int count=0;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%s%d",sz[i].x,&sz[i].y);
}
for(int j=0;j<n;j++)
{
for(int k=tag;k<n;k++)
{
if(sz[k].y>=60)
{
lnr[j].c=k;
lnr[j].b=sz[k].y;
strcpy(lnr[j].a,sz[k].x);
tag=k+1;
count++;
break;
}
}
}
for(int l=0;l<count-1;l++)
{
for(int m=count-1;m>l;m--)
{
if(lnr[m].b>lnr[m-1].b)
{
temp=lnr[m-1].b;
lnr[m-1].b=lnr[m].b;
lnr[m].b=temp;
strcpy(tem,lnr[m-1].a);
strcpy(lnr[m-1].a,lnr[m].a);
strcpy(lnr[m].a,tem);
}
}
}
tag=n-1;
for(int o=n-1;o>count-1;o--)
{
for(int p=tag;p>=0;p--)
{
if(sz[p].y<60)
{
sz[o].y=sz[p].y;
strcpy(sz[o].x,sz[p].x);
tag=p-1;
break;
}
}
}
for(int q=0;q<count;q++)
{
printf("%s\n",lnr[q].a);
}
for(int r=count;r<n;r++)
{
printf("%s\n",sz[r].x);
}
return 0;
}
| 9 |
4,067 | void main()
{
struct patient
{char id[10];
int a;
}all[100],old[100],temp;
int n,j=0,k,i;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s%d",all[i].id,&all[i].a);
if(all[i].a>=60)
{
old[j]=all[i];
j=j+1;
}
}
for(i=j-1;i>0;i--)
{
for(k=0;k<i;k++)
{
if(old[k].a<old[k+1].a)
{
temp=old[k];
old[k]=old[k+1];
old[k+1]=temp;
}
}
}
for(i=0;i<j;i++)
{
printf("%s\n",old[i].id);
}
for(i=0;i<n;i++)
{
if(all[i].a<60)
printf("%s\n",all[i].id);
}
} | 9 |
4,068 |
struct pt
{
char id[10];
int age;
};
void main()
{
int n,i,j,old;
struct pt p[100],o[100],tem;
char cao;
scanf("%d",&n);
scanf("%c",&cao);
old=0;
for(i=0;i<n;i++)
{
scanf("%s %d",p[i].id,&p[i].age);
if(p[i].age>=60) {o[old]=p[i];old++;}
}
for(i=0;i<old-1;i++)
{
for(j=0;j<old-1;j++)
{
if(o[j+1].age>o[j].age)
{
tem=o[j];
o[j]=o[j+1];
o[j+1]=tem;
}
}
}
for(i=0;i<old;i++) printf("%s\n",o[i].id);
for(i=0;i<n;i++)
{
if(p[i].age<60)
{
printf("%s\n",p[i].id);
}
}
} | 9 |
4,069 | struct Patient
{
char num[10];
int age;
struct Patient *next;
};
int main()
{
void paixu(int n,struct Patient *head);
struct Patient *creat(int n);
int n,i;
struct Patient *head;
scanf("%d",&n);
head=creat(n);
paixu(n,head);
for(i=0;i<n;i++)
{
printf("%s\n",head->num);
head=head->next;
}
}
struct Patient *creat(int n)
{
int i;
struct Patient *head,*thispoint,*nextpoint;
for(i=0;i<n;i++)
{
if(i==0)
{
nextpoint=(struct Patient *)malloc(sizeof(struct Patient));
scanf("%s %d",nextpoint->num,&nextpoint->age);
head=nextpoint;
thispoint=head;
}
else
{
nextpoint=(struct Patient *)malloc(sizeof(struct Patient));
scanf("%s %d",nextpoint->num,&nextpoint->age);
thispoint->next=nextpoint;
thispoint=nextpoint;
}
}
thispoint->next=NULL;
return head;
}
void paixu(int n,struct Patient *head)
{
int i,j,k,count;
struct Patient *p1,*p2,*p3,*p4;
char tempnum[10],tempnum3[10],tempnum4[10];
int tempage,tempage3,tempage4;
p1=head;
for(i=0;i<n-1;i++)
{
if(p1->age<60)
{
p2=p1->next;
for(j=i+1;j<n;j++)
{
if(p2->age>59)
{
strcpy(tempnum,p2->num);tempage=p2->age;
p3=p1;p4=p3->next;
for(k=i;k<j;k++)
{
strcpy(tempnum4,p4->num);tempage4=p4->age;
if(k==i){strcpy(p4->num,p3->num);p4->age=p3->age;}
else {strcpy(p4->num,tempnum3);p4->age=tempage3;}
strcpy(tempnum3,tempnum4);tempage3=tempage4;
p3=p3->next;p4=p4->next;
}
strcpy(p1->num,tempnum);p1->age=tempage;
break;
}
else p2=p2->next;
}
}
p1=p1->next;
}
p1=head;
for(i=0,count=0;i<n;i++)
{
if(p1->age>59){count++;}
p1=p1->next;
}
p1=head;
for(i=1;i<count;i++)
{
p2=p1;
for(j=0;j<count-i;j++)
{
p3=p2->next;
if(p2->age<p3->age)
{
strcpy(tempnum,p2->num);tempage=p2->age;
strcpy(p2->num,p3->num);p2->age=p3->age;
strcpy(p3->num,tempnum);p3->age=tempage;
}
p2=p2->next;
}
}
}
| 9 |
4,070 | struct p{
char id[10];
int age;
};
void bubble(struct p a[100],int n)
{
int i,j;
struct p temp;
for(i=0;i<n-1;i++)
{
for(j=0;j<n-1;j++)
{
if(a[j].age>=60)
{
if(a[j+1].age>a[j].age)
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
else
{
if(a[j+1].age>=60)
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
}
}
int main()
{
int n,i;
struct p a[100];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s%d",a[i].id,&a[i].age);
}
bubble(a,n);
for(i=0;i<n;i++)
{
printf("%s\n",a[i].id);
}
return 0;
}
| 9 |
4,071 | int main(){
int n,age[100],oage[100];
char ID[100][10],old[100][10],young[100][10];
scanf("%d",&n);
int i,m;
for(i=0;i<n;i++){
scanf("%s%d",ID[i],&age[i]);
}
int k=0,j=0;
for(i=0;i<n;i++){
if(age[i]<60){
strcpy(young[k],ID[i]);
k++;
}
else{
oage[j]=age[i];
strcpy(old[j],ID[i]);
j++;
}
}
for(i=150;i>=60;i--){
for(m=0;m<j;m++){
if(oage[m]==i){
printf("%s\n",old[m]);
}
}
}
for(i=0;i<k;i++){
printf("%s\n",young[i]);
}
return 0;
}
| 9 |
4,072 |
struct Patient
{
char id[10];
int age;
}a[100],e,b[100];
int main()
{
int n,J;
scanf("%d",&n);
int i,j;
for(i=0;i<n;i++)
{
scanf("%s %d",a[i].id,&a[i].age);
}
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
{
if(a[j].id>a[j+1].id)
{
e=a[j];a[j]=a[j+1];a[j+1]=e;
}
}
}
j=0;
for(i=0;i<n;i++)
{
if(a[i].age>=60)
{
b[j]=a[i];
j++;
}
}
J=j;
for(j=0;j<J;j++)
{
for(i=0;i<J-j;i++)
{
if(b[i].age<b[i+1].age)
{
e=b[i];
b[i]=b[i+1];
b[i+1]=e;
}
}
}
for(j=0;j<J;j++)
{
printf("%s\n",b[j].id);
}
for(i=0;i<n;i++)
{
if(a[i].age<60)
{
printf("%s\n",a[i].id);
}
}
return 0;
} | 9 |
4,073 | void main()
{
int n;
int i,j;
int k=0;
char str[100][10]={0};
char str1[100][10]={0};
char str2[100][10]={0};
int temp;
char t[10]={0};
int a[100];
int a1[100]={0};
int a2[100]={0};
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%s%d",str[i],&a[i]);
for(i=0;i<n;i++)
{
strcpy(str1[i],str[i]);
a1[i]=a[i];
}
for(i=0;i<n;i++)
if(a[i]>=60)
{
strcpy(str2[k],str[i]);
a2[k]=a[i];
k=k+1;
}
for(j=1;j<k;j++)
for(i=0;i<k-j;i++)
if(a2[i]<a2[i+1])
{
temp=a2[i];
a2[i]=a2[i+1];
a2[i+1]=temp;
strcpy(t,str2[i]);
strcpy(str2[i],str2[i+1]);
strcpy(str2[i+1],t);
}
for(i=0;i<k;i++)
printf("%s\n",str2[i]);
for(i=0;i<n;i++)
if(a1[i]<60)
printf("%s\n",str1[i]);
} | 9 |
4,074 | void main()
{
int n,i,j,z,y;
y=0;z=0;
struct member
{
char xh[10];
int ag;
};
struct member a[100];
struct member b[101],c[100];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s %d",a[i].xh,&a[i].ag);
}
for(i=0;i<n;i++)
{
if(a[i].ag>=60)
{b[y]=a[i];
y++;}
else
{c[z]=a[i];
z++;
}
}
for(i=1;i<y;i++)
{
for(j=0;j<y-i;j++)
{
if(b[j].ag<b[j+1].ag)
{
b[100]=b[j];
b[j]=b[j+1];
b[j+1]=b[100];
}
}
}
for(i=0;i<y;i++)
printf("%s\n",b[i].xh);
for(i=0;i<z;i++)
printf("%s\n",c[i].xh);
} | 9 |
4,075 | int main()
{
struct bingren
{
char num[10];
int age;
};
int n;
scanf("%d",&n);
struct bingren u[1000];
int i;
for(i=0;i<n;i++)
{
scanf("%s %d",&u[i].num,&u[i].age);
}
struct bingren v[1000];
int j=0;
for(i=0;i<n;i++)
{
if(u[i].age>59)
{v[j]=u[i];
j++;
}
}
int k;
struct bingren e;
for(k=1;k<j;k++)
{
for(i=0;i<j-k;i++)
{
if(v[i].age<v[i+1].age)
{
e=v[i+1];
v[i+1]=v[i];
v[i]=e;
}
}
}
for(i=0;i<j;i++)
{
printf("%s\n",v[i].num);
}
for(i=0;i<n;i++)
{if(u[i].age<60)
{printf("%s\n",u[i].num);}
}
return 0;
}
| 9 |
4,076 | struct bingren
{
char id[10];
int o;
}bingren[201];
void main()
{
int n,i,j,y,m;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s%d",bingren[i].id,&bingren[i].o);
}
for(i=0,j=100;i<n;i++)
{
if(bingren[i].o>=60)
{
bingren[j]=bingren[i];
j++;
}
}
y=j;
for(j=0;j<y-1;j++)
{
for(i=100;i<y-j;i++)
{
if(bingren[i].o<bingren[i+1].o)
{
bingren[200]=bingren[i];
bingren[i]=bingren[i+1];
bingren[i+1]=bingren[200];
}
}
}
for(i=100;i<y;i++)
{
printf("%s\n",bingren[i].id);
}
for(i=0;i<n;i++)
{
if(bingren[i].o<60)
printf("%s\n",bingren[i].id);
}
}
| 9 |
4,077 | int main(){
struct man
{
char a[11];
int y;
}man[100];
int n;
scanf("%d",&n);
char b[11];
int y;
int i,j;
char c[100][11];
int m=0,k=0;
for(i=0;i<n;i++){
scanf("%s%d",b,&y);
if(y>=60){
strcpy(man[k].a,b);
man[k].y=y;
k++;
}
else{
strcpy(c[m],b);
m++;
}
}
for(i=1;i<k;i++){
for(j=0;j<k-i;j++){
int y1,y2;
y1=man[j].y;
y2=man[j+1].y;
if(y1<y2){
y=man[j+1].y;
man[j+1].y=man[j].y;
man[j].y=y;
strcpy(b,man[j+1].a);
strcpy(man[j+1].a,man[j].a);
strcpy(man[j].a,b);
}
}
}
for(i=0;i<k;i++){
strcpy(b,man[i].a);
printf("%s\n",b);
}
for(i=0;i<m;i++){
strcpy(b,c[i]);
printf("%s\n",b);
}
return 0;
} | 9 |
4,078 | struct bing
{
char id[10];
int age;
int num;
}bing[100],temp;
int main ()
{
int i,j,n;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s %d",&bing[i].id,&bing[i].age);
bing[i].num=i+1;
}
for(j=0;j<=n;j++)
{
for(i=0;i<n-1;i++)
{
if(bing[i+1].age>=60&&bing[i].age<bing[i+1].age)
{
temp=bing[i+1];
bing[i+1]=bing[i];
bing[i]=temp;
}
}
}
for(i=0;i<n;i++)
printf("%s\n",bing[i].id);
return 0;
}
| 9 |
4,079 | struct pat
{
char num[10];
int age;
int x;
}p[100],P[100],s;
int main()
{
int n,i,j,k;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s %d",p[i].num,&p[i].age);
if(p[i].age>=60) p[i].x=p[i].age;
else p[i].x=0;
}
for(i=0;i<n;i++){
s.age=-1;
s.x=-1;
char k[10];
for(j=0;j<n;j++){
if(s.x<p[j].x){
s=p[j];
strcpy(k,p[j].num);
}
}
P[i]=s;
for(j=0;j<n;j++){
if(strcmp(p[j].num,k)==0){
p[j].x=-2;
break;
}
}
}
for(i=0;i<n;i++){
printf("%s\n",P[i].num);
}
return 0;
} | 9 |
4,080 | void main()
{
struct br
{ char no[10];
int s;
}a[100],b[100],r;
int n,i,j,t=0;
scanf("%d",&n);
for (i=0;i<n;i++)
{ scanf("%s %d",a[i].no,&a[i].s);
if (a[i].s>=60) { b[t]=a[i];t=t+1;}
}
for (i=0;i<t-1;i++)
for (j=0;j<t-1-i;j++)
if (b[j].s<b[j+1].s) {r=b[j];b[j]=b[j+1];b[j+1]=r;}
for (i=0;i<t;i++)
printf("%s\n",b[i].no);
for (i=0;i<n;i++)
if (a[i].s>=60) continue;
else printf("%s\n",a[i].no);
} | 9 |
4,081 | int main()
{
int n,i,j,old[100]={0},t[100]={0};
char num[100][10]={0},temp[100][10]={0};
int x,z=0;
char y[10]={0};
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s %d",num[i],&old[i]);
}
for(i=0;i<n;i++)
{
if(old[i]>=60)
{
strcpy(temp[z],num[i]);
t[z]=old[i];
z++;
}
}
for(i=0;i<z;i++)
{
for(j=z-1;j>i;j--)
{
if(t[j]>t[j-1])
{
x=t[j];
t[j]=t[j-1];
t[j-1]=x;
strcpy(y,temp[j-1]);
strcpy(temp[j-1],temp[j]);
strcpy(temp[j],y);
}
}
}
for(i=0;i<z;i++)
printf("%s\n",temp[i]);
for(i=0;i<n;i++)
{
if(old[i]<60)
printf("%s\n",num[i]);
}
return 0;
} | 9 |
4,082 | struct Pa
{
char num[20];
int year;
}pa[100];
void main()
{
int i,j,x=0,d=0,m,n;
int b[100];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s%d",pa[i].num,&pa[i].year);
}
for(i=0;i<n;i++)
b[i]=pa[i].year;
for(i=0;i<n-1;i++)
{
for(j=0;j<n-1-i;j++)
{
if(b[j]<b[j+1])
{
d=b[j];
b[j]=b[j+1];
b[j+1]=d;
}
}
}
for(i=0;i<n;i++)
{
if(b[i]>=60)
{
if(i==0)
{
for(j=0;j<n;j++)
{
if(pa[j].year==b[i])
printf("%s\n",pa[j].num);
}
}
else
{
if(b[i]!=b[i-1])
{
for(j=0;j<n;j++)
{
if(pa[j].year==b[i])
printf("%s\n",pa[j].num);
}
}
}
}
if(b[i]<60)
break;
}
for(i=0;i<n;i++)
{
if(pa[i].year<60)
printf("%s\n",pa[i].num);
}
}
| 9 |
4,083 | int main()
{
int n,i,j,k;
scanf ("%d",&n);
struct patient
{
char num[10];
int age;
};
struct patient p[100],temp;
for (i=0;i<n;i++)
scanf ("%s %d",&p[i].num,&p[i].age);
for (i=0;i<n-1;i++)
{
for (j=i+1;j<n;j++)
{
if (p[j].age>p[i].age&&p[j].age>=60)
{
for (k=j;k>i;k--)
{
temp=p[k];
p[k]=p[k-1];
p[k-1]=temp;
}
}
}
printf("%s\n",p[i].num);
}
printf("%s\n",p[n-1].num);
return 0;
}
| 9 |
4,084 | int main()
{
int n;
scanf("%d",&n);
char a[n][100];
int b[n],i,j,c[n],d[n],k;
for(i=0;i<n;i++)
scanf("%s%d",a[i],&b[i]);
for(i=0;i<n;i++)
{
c[i]=0;
d[i]=n;
for(j=0;j<n;j++)
{
if(b[j]>=60&&b[j]>c[i])
{
for(k=0;k<i;k++)
{
if(j==d[k])
break;
}
if(k==i)
{
c[i]=b[j];
d[i]=j;
}
}
}
if(d[i]!=n&&b[d[i]]>=60)
printf("%s\n",a[d[i]]);
}
for(i=0;i<n;i++)
{
if(b[i]<60)
printf("%s\n",a[i]);
}
getchar();
getchar();
}
| 9 |
4,085 | struct hospital
{
char ID [13];
int age;
struct hospital *next;
};
int main()
{
void change(struct hospital *);
int n;
scanf("%d",&n);
int i;
struct hospital *p,*head;
p=(struct hospital *)malloc(sizeof(struct hospital));
head=p;
for(i=0;i<n-1;i++)
{
scanf("%s %d",p->ID,&p->age);
p->next=(struct hospital *)malloc(sizeof(struct hospital));
p=p->next;
}
scanf("%s %d",p->ID,&p->age);
p->next=NULL;
for(i=0;i<n;i++)
{
for(p=head;p->next!=NULL;p=p->next)
{
if(p->age<60&&p->next->age>=60)
{
change(p);
}
if(p->age>=60&&p->next->age>=60&&p->next->age>p->age)
{
change(p);
}
}
}
for(p=head;p!=NULL;p=p->next)
{
printf("%s\n",p->ID);
}
return 0;
}
void change(struct hospital *p)
{
int tempage;
char tempID[13];
struct hospital *later=p->next;
tempage=later->age;
strcpy(tempID,later->ID);
later->age=p->age;
strcpy(later->ID,p->ID);
p->age=tempage;
strcpy(p->ID,tempID);
}
| 9 |
4,086 |
int main(){
struct patient{
char id[11];
int age;
} patients[100],old[100],young[100],jh;
int n,i,j,d,k;
j=-1;
d=-1;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s %d",patients[i].id,&patients[i].age);
}
for(i=0;i<n;i++){
if(patients[i].age>=60){
d++;
old[d]=patients[i];
}else{
j++;
young[j]=patients[i];
}
}
for(k=1;k<=d+1;k++){
for(i=0;i<d;i++){
if(old[i].age<old[i+1].age){
jh=old[i];
old[i]=old[i+1];
old[i+1]=jh;
}
}
}
for(i=0;i<=d;i++){
printf("%s\n",old[i].id);
}
for(i=0;i<=j;i++){
printf("%s\n",young[i].id);
}
return 0;
}
| 9 |
4,087 |
struct student
{
char num[30];
int sum;
struct student *next;
};
void main()
{
int n,i;
struct student *p1,*p2,*p3,*head;
scanf("%d",&n);
for (i=0;i<n;i++)
{
p1=(struct student*)malloc(sizeof(struct student));
if(i==0)
head=p1;
scanf("%s%d",p1->num,&p1->sum);
p1->next=NULL;
if (i!=0)
{
p3=head;
if(p1->sum>=60){
while ((p1->sum<=p3->sum) && p3->next!=NULL)
{
p2=p3;
p3=p3->next;
}
if (p1->sum > p3->sum)
{
if(head==p3)
{
head=p1;
p1->next=p3;
}
else
{
p2->next=p1;
p1->next=p3;
}
}
else
{
p3->next=p1;
p1->next=NULL;
}
}
else{for(p2=head;;p2=p2->next){if(p2->next==NULL)break;}
p2->next=p1;
p1->next=NULL;}
}
}
p1=head;
for (i=0;(i<n&&p1!=NULL);i++)
{
printf("%s\n",p1->num);
p1=p1->next;
}
}
| 9 |
4,088 | struct patient{
char id[10];
int age;
}young[100],old[100];
int main(){
int i,j,n,temp,yn=0,on=0,people[150]={0};
char t[10];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s%d",t,&temp);
if(temp>=60){
strcat(old[on].id,t);
old[on].age=temp;
on++;
people[temp]++;
}
else{
strcat(young[yn].id,t);
young[yn].age=temp;
yn++;
}
}
for(i=149;i>=60;i--){
if(people[i]>0){
for(j=0;j<on;j++)
if(old[j].age==i)
printf("%s\n",old[j].id);
}
}
for(i=0;i<yn;i++)
printf("%s\n",young[i].id);
}
| 9 |
4,089 |
struct patient
{
char id[10];
int old;
} pt[100];
main()
{
int n,i,j,k,e,h;
int yx[100],byx[100];
scanf("%d",&n);
j=0;
k=0;
for(i=0;i<n;i++){
scanf("%s %d",&pt[i].id,&pt[i].old);
if(pt[i].old>=60){
yx[j]=i;
j++;
}
else{
byx[k]=i;
k++;
}
}
for(i=0;i<j;i++){
for(h=0;h<j-1;h++){
if(pt[yx[h]].old<pt[yx[h+1]].old){
e=yx[h];
yx[h]=yx[h+1];
yx[h+1]=e;
}
}
}
for(i=0;i<j;i++){
printf("%s\n",pt[yx[i]].id);
}
for(i=0;i<k;i++){
printf("%s\n",pt[byx[i]].id);
}
}
| 9 |
4,090 | void main()
{
int n,i,j=0,k=0,l;
scanf("%d",&n);
struct p
{
char id[10];
int age;
}a[n],b[n],c[n],d;
for(i=0;i<n;i++)
{
scanf("%s %d",&a[i].id,&a[i].age);
if(a[i].age>=60) {b[j]=a[i];j++;}
else {c[k]=a[i];k++;}
}
for(i=0;i<j-1;i++)
for(l=0;l<j-1-i;l++)
if(b[l].age<b[l+1].age) {d=b[l];b[l]=b[l+1];b[l+1]=d;}
for(i=0;i<j;i++)
printf("%s\n",b[i].id);
for(i=0;i<k;i++)
printf("%s\n",c[i].id);
} | 9 |
4,091 | int main()
{
int n,i,j,t,m,l;
int b[100],d[100],g[100];
char a[100][10],c[100][10],e[10],f[100][10];
m=0;
l=0;
t=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s %d",a[i],&b[i]);
}
for(i=0;i<n;i++)
{
if(b[i]>=60)
{
strcpy(c[m],a[i]);
d[m]=b[i];
m=m+1;
}
else
{
strcpy(f[l],a[i]);
g[l]=b[i];
l=l+1;
}
}
for(i=0;i<m-1;i++)
{
for(j=0;j<m-i-1;j++)
{
if(d[j]<d[j+1])
{
t=d[j];
d[j]=d[j+1];
d[j+1]=t;
strcpy(e,c[j]);
strcpy(c[j],c[j+1]);
strcpy(c[j+1],e);
}
}
}
for(i=0;i<m;i++)
printf("%s\n",c[i]);
for(i=0;i<l;i++)
printf("%s\n",f[i]);
getchar();
getchar();
}
| 9 |
4,092 | int main()
{
int n,i,j,a[100],e;
char s[100][100],str[100];
scanf("%d\n",&n);
for(i=0;i<n;i++){
scanf("%s %d",s[i],&a[i]);
}
for(j=1;j<n;j++){
for(i=0;i<n-j;i++){
if(a[i]>=60&&a[i+1]>=60){
if(a[i]>=a[i+1]){
continue;
}
if(a[i]<a[i+1]){
strcpy(str,s[i+1]);
strcpy(s[i+1],s[i]);
strcpy(s[i],str);
e=a[i+1];
a[i+1]=a[i];
a[i]=e;
}
}
if(a[i]>=60&&a[i+1]<60){
continue;
}
if(a[i]<60&&a[i+1]>=60){
strcpy(str,s[i+1]);
strcpy(s[i+1],s[i]);
strcpy(s[i],str);
e=a[i+1];
a[i+1]=a[i];
a[i]=e;
}
if(a[i]<60&&a[i+1]<60){
continue;
}
}
}
for(i=0;i<n;i++){
printf("%s\n",s[i]);
}
return 0;
}
| 9 |
4,093 | int main()
{
int x[100],y[100],z[100],a,b=1,c=1,d=1,e=1,f,g,h,j,k,n;
char o[100][10],p[100][10],q[100][10],r[100][10];
scanf("%d",&n);
for(a=1;a<=n;a++)
{
scanf("%s",o[a]);
scanf("%d",&x[a]);
if(x[a]>=60)
{
strcpy(p[b],o[a]);
b++;
y[c]=x[a];
c++;
}
else
{
strcpy(q[d],o[a]);
d++;
z[e]=x[a];
e++;
}
}
for(f=1;f<=b-2;f++)
{
for(g=1;g<=b-2;g++)
{
if(y[g]<y[g+1])
{
h=y[g];
y[g]=y[g+1];
y[g+1]=h;
strcpy(r[1],p[g]);
strcpy(p[g],p[g+1]);
strcpy(p[g+1],r[1]);
}
}
}
for(j=1;j<=b-1;j++)
{
printf("%s\n",p[j]);
}
for(k=1;k<=d-1;k++)
{
printf("%s\n",q[k]);
}
return 0;
} | 9 |
4,094 |
int main(int argc, char* argv[])
{
int n,j=0,i,num=0,t;
char a[100][10],d[100][10],temp[10];//a???????d?a???
int b[100],c[100];//b???????c?b???
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s %d",a[i],&b[i]);//??
}
for(i=0;i<n;i++){
if(b[i]>=60){
c[j]=b[i];
strcpy(d[j],a[i]);
j++;
num=j;//???????65????????c?????????
}
}
for(i=1;i<num;i++)
for(j=0;j<num-i;j++){
if(c[j]<c[j+1]){
t=c[j+1];
c[j+1]=c[j];
c[j]=t;
strcpy(temp,d[j+1]);
strcpy(d[j+1],d[j]);
strcpy(d[j],temp);//?????65???????????????
}
}
for(i=0;i<n;i++){
if(b[i]<60){
c[num]=b[i];
strcpy(d[num],a[i]);
num++;//???65????c?????????
}
}
for(j=0;j<n;j++){
printf("%s\n",d[j]);//???????
}
return 0;
}
| 9 |
4,095 | struct patient
{ char ID[10];
int age;
int a6;
char Id[10];
};
void main()
{ struct patient bin[N];
int n,mid;
char s[10];
int i=0,j=0,k=0;
char c[10];
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%s%d",&bin[i].ID,&bin[i].age);
for(i=0;i<n;i++)
{ if(bin[i].age>=60)
{ bin[j].a6=bin[i].age;
strcpy(bin[j].Id,bin[i].ID);
j++;
bin[i].age=0;
}
}
for(k=1;k<j;k++)
{ for(i=0;i<j-k;i++)
if(bin[i].a6<bin[i+1].a6)
{ mid=bin[i].a6;
bin[i].a6=bin[i+1].a6;
bin[i+1].a6=mid;
strcpy(c,bin[i].Id);
strcpy(s,bin[i+1].Id);
strcpy(bin[i+1].Id,c);
strcpy(bin[i].Id,s);
}
}
for(i=0;i<j;i++)
printf("%s\n",bin[i].Id);
for(i=0;i<n;i++)
{ if(bin[i].age!=0)
printf("%s\n",bin[i].ID);
}
}
| 9 |
4,096 | int main()
{
int n,m=0;
scanf("%d\n",&n);
struct p{
char num[10000];
int age;
}p[100];
struct p1{
char num1[10000];
int age1;
}p1[100];
int i,j;
for(i=0;i<n;i++)
{
scanf("%s%d\n",p[i].num,&p[i].age);
if(p[i].age>=60)
{
strcpy(p1[m].num1,p[i].num);
p1[m].age1=p[i].age;
m=m+1;
}
}
int e;
char w[10000];
for(i=1;i<m;i++)
{
for(j=0;j<m-i;j++)
{
if(p1[j].age1<p1[j+1].age1)
{
strcpy(w,p1[j+1].num1);
strcpy(p1[j+1].num1,p1[j].num1);
strcpy(p1[j].num1,w);
e=p1[j+1].age1;
p1[j+1].age1=p1[j].age1;
p1[j].age1=e;
}
}
}
for(i=0;i<m;i++)
{
printf("%s\n",p1[i].num1);
}
for(i=0;i<n;i++)
{
if(p[i].age<60)
{
printf("%s\n",p[i].num);
}
}
return 0;
}
| 9 |
4,097 | struct patient
{ char id[11];
int age,seq;
struct patient *next;
};
main()
{ int n,n1=0,n2=0,i,j,m,at;
char id[10];
struct patient *head1,*head2,*p11,*p12,*p21,*p22,*t,*q;
scanf("%d",&n);
head1=NULL;
head2=NULL;
for(i=0;i<n;i++)
{
scanf("%s%d",id,&at);
if(at>=60)
{ if(head1==NULL)
{
head1=(struct patient*)malloc(sizeof(struct patient));
strcpy(head1->id,id);
head1->age=at;
head1->next=NULL;
}
else
{ for(t=head1,q=t;t!=NULL;q=t,t=t->next)
{ if(t->age<at&&t!=head1)
{
p11=(struct patient *)malloc(sizeof(struct patient));
p11->age=at;
strcpy(p11->id,id);
q->next=p11;
p11->next=t;
break;
}
if(t->age<at&&t==head1)
{
p11=(struct patient *)malloc(sizeof(struct patient));
p11->age=at;
strcpy(p11->id,id);
p11->next=head1;
head1=p11;
break;
}
/* if(t->age==at)
{
p11=(struct patient *)malloc(sizeof(struct patient));
p11->age=at;
strcpy(p11->id,id);
p11->next=t->next;
t->next=p11;
break;
} */
}
if(t==NULL)
{
p11=(struct patient *)malloc(sizeof(struct patient));
p11->age=at;
strcpy(p11->id,id);
q->next=p11;
p11->next=NULL;
}
}
}
if(at<60)
{ if(head2==NULL)
{
head2=(struct patient*)malloc(sizeof(struct patient));
strcpy(head2->id,id);
head2->age=at;
head2->next=NULL;
p22=head2;
}
else
{
p21=(struct patient *)malloc(sizeof(struct patient));
p21->age=at;
strcpy(p21->id,id);
p22->next=p21;
p21->next=NULL;
p22=p21;
}
}
}
for(t=head1,q=t;t!=NULL;q=t,t=t->next);
q->next=head2;
for(t=head1;t->next!=NULL;t=t->next)
{ printf("%s\n",t->id);
}
printf("%s",t->id);
} | 9 |
4,098 | int main()
{
int n,sz[100],zs[100],i,k=0,m,a;
char id[100][10],di[100][10],zfc[10];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s %d",id[i],&(sz[i]));
}
for(i=0;i<n;i++)
{
if(sz[i]>=60)
{
zs[k]=sz[i];
strcpy(di[k],id[i]);
k++;
}
}
for(m=0;m<k-1;m++)
{
for(i=0;i<k-1-m;i++)
{
if(zs[i]<zs[i+1])
{
a=zs[i];
zs[i]=zs[i+1];
zs[i+1]=a;
strcpy(zfc,di[i]);
strcpy(di[i],di[i+1]);
strcpy(di[i+1],zfc);
}
}
}
for(i=0;i<n;i++)
{
if(sz[i]<60)
{
strcpy(di[k],id[i]);
k++;
}
}
for(i=0;i<k;i++)
{
printf("%s\n",di[i]);
}
return 0;
} | 9 |
4,099 | int main()
{
int n,i,j,k;
int age[1000],a[1000],t;
char ID[1000][1000];
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%s %d",&ID[i],&age[i]);
j=n-1;
k=0;
for(i=n-1;i>=0;i--)
{
if(age[i]<60)
{
a[j]=i;
j--;
}
}
for(i=0;i<n;i++)
{
if(age[i]>=60)
{
a[k]=i;
k++;
}
}
for(i=0;i<k;i++)
{
for(j=k-1;j>i;j--)
{
if(age[a[j]]>age[a[j-1]])
{
t=a[j];
a[j]=a[j-1];
a[j-1]=t;
}
}
}
for(i=0;i<n;i++)
printf("%s\n",ID[a[i]]);
getchar();
getchar();
getchar();
return 0;
}
| 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.