id
int32
0
32.5k
code
stringlengths
95
8.4k
label
stringclasses
65 values
15,300
struct student { char num[15]; char name[30]; char sex; char age[3]; char grade[10]; char ad[15]; }stu[1000]={0}; int main() { int i=0; while(1) { scanf("%s",stu[i].num); if(stu[i].num[0]=='e') break; else { scanf("%s %c %s %s %s",stu[i].name,&stu[i].sex,stu[i].age,stu[i].grade,stu[i].ad); i++; } } i=i-1; for(;i>=0;i--) { printf("%s %s %c %s %s %s\n",stu[i].num,stu[i].name,stu[i].sex,stu[i].age,stu[i].grade,stu[i].ad); } return 0; }
31
15,301
void main() { char s[1024][128]; int i=0; while(gets(s[i])) { if(strcmp(s[i],"end")==0) break; i++; } while(i!=0) { i--; puts(s[i]); } }
31
15,302
struct student { char num[10]; char name[20]; char sex; int age; char score[10]; char add[15]; struct student *next; }; void main() { struct student *p1,*p2,*head; int n=0; p1=p2=(struct student*)malloc(LEN); p1->next=NULL; scanf("%s",p1->num); while(strcmp(p1->num,"end")!=0) { scanf("%s %c %d %s %s\n",p1->name,&p1->sex,&p1->age,p1->score,p1->add); n++; p2=(struct student*)malloc(LEN); p2->next=p1; p1=p2; scanf("%s",p1->num); } head=p1->next; p1=head; while(p1->next!=NULL) { printf("%s %s %c %d %s %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->add); p1=p1->next; } printf("%s %s %c %d %s %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->add); }
31
15,303
struct stu { char zifu[200]; struct stu *next; }; struct stu stu[1000]; void main() { int i; struct stu *p=stu; for(i=0;i<1000;i++,p++) { gets(p->zifu); char str[10]="end"; if((strcmp(p->zifu,str))==0) break; p->next=(p-1); } p=p-1; stu[0].next=NULL; while(p!=NULL) { puts(p->zifu); p=p->next; } }
31
15,304
int n=0; struct student { char id[20]; char name[20]; char sex; int age; char score[20]; char address[20]; struct student* next; }; struct student *creat() { struct student* head,*pf,*ps; pf= (struct student * ) malloc(sizeof(struct student)); ps=pf; scanf("%s",&pf->id); while(pf->id[0]!='e') { n++; scanf("%s %c %d %s %s",&pf->name,&pf->sex,&pf->age,&pf->score,&pf->address); if(n!=1) { pf->next=ps; ps=pf; } else pf->next=NULL; pf=(struct student*)malloc(sizeof(struct student)); scanf("%s",&pf->id); } head=ps; return head; } void print(struct student *head) { int i; struct student *p; p=head; if(head!=NULL) for(i=0;i<n;i++) { printf("%s %s %c %d %s %s\n",p->id,p->name,p->sex,p->age,p->score,p->address); p=p->next; } } void main() { struct student *head; head=creat(); print(head); }
31
15,305
struct student { char num[10]; char name[20]; char sex; int age; char score[10]; char id[20]; struct student *pre; }; void main() { struct student *p1,*p2,*end; p1=(struct student *)malloc(sizeof(struct student)); end=p1; p2=p1; p1->pre=NULL; scanf("%s %s %c %d %s %s",p1->num,p1->name,&p1->sex,&p1->age,p1->score,p1->id); for(;1;) { p1=(struct student *)malloc(sizeof(struct student)); scanf("%s",p1->num); if(strcmp(p1->num,"end")==0){end=p2;break;} else scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->id); p1->pre=p2; p2=p1; } p1=end; for(;p1!=NULL;) { printf("%s %s %c %d %s %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->id); p1=p1->pre; } }
31
15,306
struct student {char num[20]; char name[20]; char sex; int age; char score[20]; char add[20]; struct student *next; }; int main() { struct student *p; struct student *p1,*p2; p1=(struct student*)malloc(len); (*p1).next=0; scanf("%s",(*p1).num); while((*p1).num[0]!='e'){ scanf("%s %c %d %s %s",(*p1).name,&(*p1).sex,&(*p1).age,(*p1).score,(*p1).add); p2=p1; p1=(struct student*)malloc(len); (*p1).next=p2; scanf("%s",(*p1).num); } p=p2; while(p){ printf("%s %s %c %d %s %s\n",(*p).num,(*p).name,(*p).sex,(*p).age,(*p).score,(*p).add); p=(*p).next; } return 0; }
31
15,307
struct stu { char infor[1000]; struct stu *next; } *p1,*p2; struct stu *creat(void) { struct stu *head=NULL; p2=p1=(struct stu*)malloc(sizeof(struct stu)); gets(p1->infor); while(strcmp(p1->infor,"end")) { if(head==NULL) head=p1; else p2->next=p1;p2=p1; p1=(struct stu*)malloc(sizeof(struct stu)); gets(p1->infor); } p2->next=NULL; return(head); } struct stu *back(struct stu *head) { struct stu *newp,*newhead=NULL; do{ p2=NULL;p1=head; while(p1->next!=NULL) {p2=p1;p1=p1->next;} if(newhead==NULL) newhead=p1,newp=newhead->next=p2; newp=newp->next=p2; p2->next=NULL; }while(head->next!=NULL); return (newhead); } void main() {struct stu *head; head=creat(); head=back(head); for(p1=head;p1!=NULL;p1=p1->next) printf("%s\n",p1->infor); }
31
15,308
struct stu { //???????? char stunum[10]; char name[20]; char sex[3]; char age[10]; char mark[10]; char add[20]; struct stu *next,*before;//?? }; void main() { struct stu *p,*pt,*head; int i=0,n=0; char a[4]; strcpy(a, "end"); pt=p=head=(struct stu *)malloc(Len); for(i=0;;i++) { scanf("%s",&p->stunum); if(strcmp(p->stunum,a)==0) { pt->next=NULL;break; } scanf("%s %s %s %s %s",&p->name,&p->sex,&p->age,&p->mark,&p->add); pt=p; p=(struct stu *)malloc(Len); pt->next=p; p->before=pt; } p=pt; if(p!=head) { for(i=0;;i++) { printf("%s %s %s %s %s %s",&p->stunum,&p->name,&p->sex,&p->age,&p->mark,&p->add); if(p==head) break; printf("\n"); p=p->before; } } printf("\n"); }
31
15,309
typedef struct linknode { char inf[500]; struct linknode *next,*prev; } snode,*ptr; main () { int i,a1,a2,j,min,k; ptr head,p1,p2,p3; k=0; for (i=1;i<=5;i) { p1=(ptr)malloc(sizeof(snode)); if (k==0) {head=p1; p2=p1;} else {(*p2).next =p1; (*p1).prev=p2;} gets((*p1).inf); if ((*p1).inf[0]!='e') { p2=p1; k++; } else { p1=p2; i=6; } } for (i=1;i<=k;i++) { printf ("%s\n",(*p1).inf ); if (i!=k) p1=(*p1).prev ; } }
31
15,310
struct student {char num[20]; char name[20]; char sex; int age; float score; char address[20]; struct student *next; }; void main() { struct student *p1,*p2,*head,*p; p1=p2=(struct student *) malloc(LEN); scanf("%s",p1->num); p1->next=NULL; while(p1->num[0]!='e') { scanf("%s %c%d%f%s",p1->name,&p1->sex,&p1->age,&p1->score,p1->address); p1=(struct student *) malloc(LEN); p1->next=p2; p2=p1; scanf("%s",p1->num); } p=head=p2->next; while(p!=NULL) { printf("%s %s %c %d %g %s\n",p->num,p->name,p->sex,p->age,p->score,p->address); p=p->next; } }
31
15,311
struct student { char num[30];//???????end??strcpy?? char name[30]; char sex; int age; char score[30];//??????????? char add[30]; struct student *next; }*p1,*p2;//??????????? int n;//???? struct student *creat(void) //???? { struct student *head=NULL; char temp[30]={"end"}; n=0; p1=p2=(struct student*)malloc(LEN);// ????? scanf("%s",p1->num); while(strcmp(p1->num,temp)!=0)//?????end??? { scanf(" %s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->add); n=n+1; if(n==1) head=p1;//???? else p2->next=p1; p2=p1; p1=(struct student*)malloc(LEN);// ????? scanf("%s",p1->num);//????????while?? } p2->next=NULL; return(head); } struct student*change(struct student *head)//???? { struct student *head1,*head2=NULL; do{ p2=NULL; p1=head; while(p1->next!=NULL)//?p1???? { p2=p1; p1=p1->next; } if(head2==NULL) { head2=p1;//????? head1=head2->next=p2; } head1=head1->next=p2;//???????? p2->next=NULL; }while(head->next!=NULL); return(head2); } void print(struct student *head)//?? { struct student *p1; p1=head; while(p1!=NULL) { printf("%s %s %c %d %s %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->add); p1=p1->next; } printf("\n"); } int main() { struct student *head; head=creat(); head=change(head); print(head); return 0; }
31
15,312
struct student { char seq[10]; char other[100]; struct student *next; struct student *previous; }; void main() { struct student *p1,*p2; int n=1; p1=p2=(struct student *)malloc(LEN); while(n++) { scanf("%s",p1->seq); if (strcmp(p1->seq,"end")==0) break; gets(p1->other); if (n>1) p1->previous=p2; p2=p1; p2->next=p1= (struct student *)malloc(LEN); } p1=p2; n=n-1; for (n;n>1;n--) { printf("%s%s\n",p1->seq,p1->other); p1=p1->previous; } }
31
15,313
struct stu { char num[21]; char name[21]; char sex; int age; char score[11]; char addr[21]; struct stu *pre,*next; }head,end; void create() { struct stu *p1,*p2; p2=&head; p1=(struct stu *)malloc(sizeof(struct stu)); scanf("%s",p1->num); while (strcmp(p1->num,"end")!=0) { p2->next=p1; p1->pre=p2; scanf("%s",p1->name); scanf(" %c",&p1->sex); scanf("%d",&p1->age); scanf("%s",p1->score); scanf("%s",p1->addr); p2=p1; p1=(struct stu *)malloc(sizeof(struct stu)); scanf("%s",p1->num); } p2->next=&end; end.pre=p2; } void anti_print() { struct stu *p; int flag=0; p=end.pre; while (p!=&head) { if (flag) printf("\n"); printf("%s",p->num); printf(" %s",p->name); printf(" %c",p->sex); printf(" %d",p->age); printf(" %s",p->score); printf(" %s",p->addr); p=p->pre; flag=1; } } void main() { head.pre=NULL; end.next=NULL; create(); anti_print(); }
31
15,314
struct student { char all[100]; struct student *next; }; main() { int k; int a=0; struct student *p; struct student *head; struct student *p1,*p2; p1=p2=(struct student *)malloc(n); head=NULL; k=0; for(k=0;;k++) { gets(p1->all); a++; if((p1->all)[0]!='e') { if(a==1) p1->next=NULL; else p1->next=p2; p2=p1; p1=(struct student *)malloc(n); } else { head=p2; break; } } p=head; while(p!=NULL) { puts(p->all); p=p->next; } }
31
15,315
struct student { char _no[9]; char name[20]; char sex[1]; int age; float score; char add[20]; struct student *next; }; int n; void main() { int i; struct student *p1; struct student *p2; struct student *head; n=0; p1=p2=(struct student*)malloc(LEN); head=NULL; for(n=0;;) { n=n+1; p1=(struct student*)malloc(LEN); if(n==1) { p2->next=NULL; } { scanf("%s",p1->_no); if(p1->_no[0]!='e') { scanf("%s%s%d%f%s",p1->name,p1->sex,&p1->age,&p1->score,p1->add); p1->next=p2; p2=p1; } else { head=p2; break; } } } p1=head; for(i=0;p1->next!=NULL;i++) { printf("%s %s %s %d %g %s\n",p1->_no,p1->name,p1->sex,p1->age,p1->score,p1->add); p1=p1->next; } }
31
15,316
//#define LEN sizeof(struct student) struct student { char num[50]; struct student * next; }; int n; char end[4]="end"; struct student * creat(void) { struct student * p1,*p2; n=0; p1=p2=(struct student*)malloc(sizeof(struct student));// gets(p1->num); while(strcmp(end,p1->num)!=0)// { n=n+1; if(n==1) p2->next=NULL; else p1->next=p2; p2=p1; p1=(struct student *)malloc(sizeof(struct student)); gets(p1->num); } return(p2); } void print(struct student * p2) { struct student *p; p=p2; do{ printf("%s\n",p->num); p=p->next; }while(p!=NULL); } int main() { print(creat()); return 0; }
31
15,317
/* * 78.cpp * ?????? * Created on: 2011-12-11 * ?????????????????????????????????????????? */ int main() { int i,j; struct { char number[40]; char name[40]; char sex; int old; double point; char address[40]; }student[1000]; for(i=0;i<1000;i++) { cin>>student[i].number; if((student[i].number[0]=='e')&&(student[i].number[1]=='n')&&(student[i].number[2]=='d')&&(student[i].number[3]=='\0')) break; cin>>student[i].name>>student[i].sex>>student[i].old>>student[i].point>>student[i].address; } for(j=i-1;j>=0;j--) { cout<<student[j].number<<" "<<student[j].name<<" "<<student[j].sex<<" "<<student[j].old<<" "<<student[j].point<<" "<<student[j].address<<endl; } return 0; }
31
15,318
int main() { int i,m; char a[501][500]; for(i=0;;i++) { gets(a[i]); if (a[i][0]=='e') { m=i; break; } } for(i=m-1;i>=0;i--) { puts(a[i]); } return 0; }
31
15,319
main() { int n=0; struct b { char a[60]; }d,*q[10000]; while(1) { gets(d.a); if(d.a[0]=='e') break; q[n]=(struct b *)malloc(sizeof(struct b)); *q[n]=d; n++; } while(n--) { puts(q[n]->a); } }
31
15,320
void main() { struct st { char num[500]; char name[500]; char sex; int age; double mark; char adress[500]; struct st *next; }*p,*p1,*p2; p2=NULL; while(1) { p1=(struct st*)malloc(sizeof(struct st));p1->next=p2;p2=p1; scanf("%s",p1->num);if(strcmp("end",p1->num)==0){p=p1->next;break;} scanf("%s %c %d %lf %s",p1->name,&p1->sex,&p1->age,&p1->mark,p1->adress); } while(p!=NULL) { printf("%s %s %c %d %g %s\n",p->num,p->name,p->sex,p->age,p->mark,p->adress); p=p->next; } }
31
15,321
struct student { char num[20]; char name[20]; char sex; int age; char score[10]; char add[30]; struct student *next; }*p1,*p2; struct student *input(void) { char temp[100]={0}; struct student *head=NULL; while(gets(temp)) { if(strcmp(temp,"end")==0)break; p1=(struct student *)malloc(sizeof(struct student)); sscanf(temp,"%s%s %c %d %s%s",p1->num,p1->name,&p1->sex,&p1->age,p1->score,p1->add); if(head==NULL) { head=p1,p2=p1; } else { p2->next=p1; p2=p1; p2->next=NULL; } } return(head); } struct student *sort(struct student *head) { struct student *n,*newhead=NULL; do { p2=NULL; p1=head; while(p1->next!=NULL) p2=p1,p1=p1->next; if(newhead==NULL) newhead=p1,n=newhead->next=p2; n=n->next=p2; p2->next=NULL; }while(head->next!=NULL); return(newhead); } void output(struct student *outhead) { for(p1=outhead;p1!=NULL;p1=p1->next) printf("%s %s %c %d %s %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->add); } int main() { struct student *head; head=input(); head=sort(head); output(head); printf("\n"); return 0; }
31
15,322
typedef struct student { char num[20]; char name[20]; char sex[2]; char age[3]; char mark[10]; char add[30]; struct student *next; } stu; int n; stu* rcreate() { stu *head,*p; head=p=(stu*)malloc(LEN); scanf("%s",p->num); p->next=NULL; if(strcmp(p->num,"end")==0) { head=NULL; return(NULL); } while(strcmp(p->num,"end")!=0) { scanf("%s %s %s %s %s",p->name,p->sex,p->age,p->mark,p->add); p=(stu*)malloc(LEN); p->next=head; head=p; scanf("%s",p->num); } head=p->next; free(p); return(head); } void print(stu* head) { stu *p; p=head; if(p==NULL) { printf("list null!"); return; } while(p->next!=NULL) { printf("%s %s %s %s %s %s\n",p->num,p->name,p->sex,p->age,p->mark,p->add); p=p->next; } printf("%s %s %s %s %s %s\n",p->num,p->name,p->sex,p->age,p->mark,p->add); } void main() { stu *h; h=rcreate(); print(h); }
31
15,323
struct student { char num[9]; char name[20]; char sex; int age; char grade[6]; char add[11]; struct student*next; }; int n=0; void main() { struct student *head; struct student *p1,*p2,*temp,*p=NULL; p1=p2=(struct student*)malloc(LEN); scanf("%s",p1->num); scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->grade,p1->add); head=NULL; while(strcmp(p1->num,"end")!=0) { n=n+1; if(n==1)head=p1; else p2->next=p1; p2=p1; p1=(struct student*)malloc(LEN); scanf("%s",p1->num); if(strcmp(p1->num,"end")==0)break; scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,&p1->grade,p1->add); } p2->next=NULL; do { p2=NULL; p1=head; while(p1->next!=NULL) { p2=p1; p1=p1->next; } if(p==NULL) { p=p1; temp=p->next=p2; } temp=temp->next=p2; p2->next=NULL; }while(head->next!=NULL); do{ printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->grade,p->add); p=p->next; }while(p!=NULL); }
31
15,324
struct a { char s[6][100]; struct a *next; }head; int tot=0; void init() { int i; struct a *p; head.next=NULL; while(1) { p=(struct a *)malloc(sizeof(struct a)); scanf("%s",p->s[0]); if(!strcmp(p->s[0],"end")) break; for(i=1;i<6;i++) { scanf("%s",p->s[i]); } p->next=head.next; head.next=p; } } void print() { struct a *p=head.next; int i; while(p) { for(i=0;i<5;i++) { printf("%s ",p->s[i]); } puts(p->s[i]); p=p->next; } } int main() { init(); print(); return 0; }
31
15,325
struct link { char s[100]; struct link *next; struct link *last; } ; struct link *create() { struct link *last,*head,*p; char s[100]; head=(struct link*)malloc(LEN); last=head; do { gets(s); if (strlen(s)==3) break; p=(struct link*)malloc(LEN); strcpy(p->s,s); last->next=p; p->last=last; last=p; } while (0==0); last->next=NULL; head=head->next; head->last=NULL; return head; } void nprint(struct link *p) { struct link *last; while (p!=NULL) { last=p; p=p->next; } p=last; while (p!=NULL) { puts(p->s); p=p->last; } } int main() { struct link *p; p=create(); nprint(p); }
31
15,326
struct student { char num[30]; char name[30]; char s; float grad1; float grad2; char add[30]; struct student *next,*prev; }; void main() { struct student *head,*temp,*end; head=(struct student *)malloc(sizeof(struct student)); temp=head; head->prev=0; while(1) { scanf("%s",temp->num); if(strcmp(temp->num,"end")==0) break; scanf("%s %c %f %f %s",temp->name,&temp->s,&temp->grad1 ,&temp->grad2,temp->add ); temp->next=(struct student *)malloc(sizeof(struct student)); temp->next->prev =temp; temp=temp->next; } end=temp->prev; end->next=0; temp=end; while(temp!=0) { printf("%s %s %c %g %g %s\n",temp->num ,temp->name,temp->s,temp->grad1 ,temp->grad2,temp->add ); temp=temp->prev; } }
31
15,327
int main() { struct student { char ID[30]; char name[30]; char sex; int age; float score; char address[20]; }message[1000]; int num=0; for(;;num++) { cin>>message[num].ID; if (message[num].ID[0]!='e')//?????? {cin>>message[num].name>>message[num].sex>>message[num].age>>message[num].score>>message[num].address; } else break; } for(int i=num-1;i>=0;i--) cout<<message[i].ID<<' '<<message[i].name<<' '<<message[i].sex<<' '<<message[i].age<<' '<<message[i].score<<' '<<message[i].address<<endl; return 0; }
31
15,328
struct student { char id[20]; char name[30]; char sex; int age; char score[30]; char add[30]; struct student *next; struct student *adv; }; int n; void main() { struct student *p,*q,*head; n=0; p=q=(struct student *)malloc(LEN); scanf("%s %s %c %d %s %s",p->id,p->name,&(*(p)).sex,&(*(p)).age,p->score,p->add); head=NULL; while(strcmp(p->id,"end")!=0) { n=n+1; if(n==1) {p->adv=NULL;head=p;} else q->next=p; p->adv=q; q=p; p=(struct student *)malloc(LEN); scanf("%s %s %c %d %s %s",p->id,p->name,&p->sex,&p->age,p->score,p->add); } q->next=NULL; while(q!=NULL) { if(q!=head) {printf("%s %s %c %d %s %s\n",q->id,q->name,(*(q)).sex,(*(q)).age,q->score,q->add); q=q->adv;} else {printf("%s %s %c %d %s %s\n",head->id,head->name,(*(head)).sex,(*(head)).age,head->score,head->add);break;} } }
31
15,329
struct stu { char xh[20],mz[20],xb,dz[20],df[20]; int nl; }; int main() { struct stu a[10000]; int n=0,i; char str[4]="end",c; scanf("%s",a[0].xh); while(strcmp(a[n].xh,str)!=0) { scanf("%s",a[n].mz); c=getchar(); scanf("%c",&a[n].xb); scanf("%d",&a[n].nl); scanf("%s",&a[n].df); c=getchar(); scanf("%s",a[n].dz); c=getchar(); n++; scanf("%s",a[n].xh); c=getchar(); } for(i=n-1;i>=0;i--) printf("%s %s %c %d %s %s\n",a[i].xh,a[i].mz,a[i].xb,a[i].nl,a[i].df,a[i].dz); return 0; }
31
15,330
struct student { char num[10]; char name[20]; char sex[2]; int age; float score; char address[40]; struct student *next; }; void main() { struct student *p,*p1,*p2; p1=(struct student *)malloc(len); p1->next=NULL; scanf("%s",p1->num); while(p1->num[0]!='e') { scanf("%s%s%d%f%s",p1->name,p1->sex,&p1->age,&p1->score,p1->address); p2=p1; p1=(struct student*)malloc(len); p1->next=p2; scanf("%s",p1->num); } if(p2->next!=NULL){ for(p=p2;p->next!=NULL;p=p->next) { printf("%s %s %s %d %g %s\n",p->num,p->name,p->sex,p->age,p->score,p->address); } printf("%s %s %s %d %g %s\n",p->num,p->name,p->sex,p->age,p->score,p->address); } if(p2->next=NULL) printf("%s %s %s %d %g %s\n",p2->num,p2->name,p2->sex,p2->age,p2->score,p2->address); }
31
15,331
void main() { char a[200]; gets(a); if(a[0]-'e'||a[1]-'n'||a[2]-'d') { main(); puts(a); } }
31
15,332
struct w {char id[100]; struct w *next; }; struct w *head,*new,*newhead,*p1,*p2; int i,n; void main() { n=0; head=null; p1=p2=(struct w *)malloc(len); gets(p1->id); while(strcmp(p1->id,"end")!=0) { n++; if(n==1)head=p1; else p2->next=p1; p2=p1; p1=(struct w *)malloc(len); gets(p1->id); } p2->next=null; for(i=0;i<n;i++) {p2=p1=head; while(p1->next!=null) {p2=p1;p1=p1->next;} if(i==0) newhead=new=p1; else new=new->next=p1; p2->next=null; } p1=newhead; for(i=0;i<n;i++) {printf("%s\n",p1->id); p1=p1->next; } }
31
15,333
struct student {char num[10]; char name[20]; char sex; int age; char score[10]; char adr[30]; struct student *previous; }; void main() {struct student *end,*head; struct student *p1,*p2, *p; /*p1=(struct student *)malloc(LEN);*/ p2=head=NULL; while(1) {p1=(struct student*)malloc(LEN); scanf("%s",&p1->num); if (strcmp(p1->num,"end")==0){/*delete p1;*/break;} scanf(" %s %c %d %s %s",&p1->name,&p1->sex,&p1->age,&p1->score,&p1->adr); if(head==NULL)head=p1; else p1->previous=p2; p2=p1; } /*p1->previous=p2;*/ end=p2; p=end; if(end!=NULL) do {printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->adr); p=p->previous; }while(p!=NULL); }
31
15,334
struct student { char a[100]; struct student *next; }; struct student *create() { struct student *p1,*p2; p1=(struct student*)malloc(len); gets(p1->a); p1->next=NULL; p2=p1; for(;;) { p1=(struct student*)malloc(len); gets(p1->a); if(strcmp(p1->a,"end")==0) { free(p1); break; } p1->next=p2; p2=p1; } return p2; } void main() { struct student *head,*p1; struct student *create(); head=create(); p1=head; while(p1) { printf("%s\n",p1->a); p1=p1->next; } }
31
15,335
struct student { char number[100]; char name[100]; char sex; int age; char score[100]; char address[100]; struct student *prev; struct student *next; }; int main() { struct student *phead,*p,*q; char m[10]; phead=(struct student*)malloc(sizeof(struct student)); phead->prev=NULL; scanf("%s",m); q=phead; do { p=(struct student*)malloc(sizeof(struct student)); strcpy(p->number, m); scanf("%s %c %d %s %s",p->name,&p->sex,&p->age,&p->score,p->address); p->prev=q; q->next=p; q=q->next; scanf("%s",m); } while (strcmp(m,"end")!=0); q->next=NULL; p=phead; while (p->next!=NULL) p=p->next; while (p!=phead) { printf("%s %s %c %d %s %s\n",p->number,p->name,p->sex,p->age,p->score,p->address); p=p->prev; } }
31
15,336
struct student { char num[10]; char name[20]; char sex; int age; char score[6]; char addr[20]; struct student *former; }; int n; struct student *create() { n=0; struct student *p1,*p2; p1=p2=(struct student*)malloc(LEN); scanf("%s",p1->num); while(p2->num[0]!='e') { n++; if(n==1) p1->former=NULL; else p2->former=p1; p1=p2; scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->addr); p2=(struct student*)malloc(LEN); scanf("%s",p2->num); } return(p1); } void print(struct student*head) { struct student *p; p=head; while(p!=NULL) { printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->addr); p=p->former; } } void main() { struct student *head; head=create(); print(head); }
31
15,337
struct Student { char r[200]; struct Student *next,*up; }; int main() { struct Student *p,*h,*pre; h=NULL; while (1) { p=malloc(L); if (h==NULL) { h=p; p->up=h; } else { pre->next=p; p->up=pre; } gets(p->r); if (strcmp(p->r,"end")==0) break; //scanf("\n"); pre=p; } p=pre; while (1) { printf("%s",p->r); if (p==h) break; else printf("\n"); p=p->up; } return 0; }
31
15,338
main() { struct INF {char a1[20];char a2[20]; char a3[20];char a4[20];char a5[20]; char a6[20];struct INF *pp;} *p1,*p2; p1=(struct INF *)malloc(sizeof(struct INF)); p2=NULL; int n=0,i; scanf("%s",p1->a1); while (strcmp(p1->a1,"end")!=0) { scanf("%s",p1->a2); scanf("%s",p1->a3); scanf("%s",p1->a4); scanf("%s",p1->a5); scanf("%s",p1->a6); p1->pp=p2; p2=p1; p1=(struct INF *)malloc(sizeof(struct INF)); scanf("%s",p1->a1); n++; } for (i=0;i<n;i++) {printf("%s %s %s %s %s %s\n",p2->a1,p2->a2,p2->a3,p2->a4,p2->a5,p2->a6); p2=p2->pp;} }
31
15,339
struct Student { char number[100]; char name[100]; char sex; int age; char score[20]; char address[100]; struct Student *next; struct Student *front; }; int n; void main() { struct Student*p1,*p2; n=0; p1=p2=(struct Student*)malloc(LEN); scanf("%s %s %c%d%s%s",&p1->number,&p1->name,&p1->sex,&p1->age,&p1->score,&p1->address); p1->front=NULL; while(p1->number[0]!='e'||p1->number[1]!='n'||p1->number[2]!='d') { n=n+1; p2=p1; p1=(struct Student*)malloc(LEN); scanf("%s %s %c%d%s%s",&p1->number,&p1->name,&p1->sex,&p1->age,&p1->score,&p1->address); p1->front=p2; } while(p2!=NULL) { printf("%s %s %c %d %s %s\n",p2->number,p2->name,p2->sex,p2->age,p2->score,p2->address); p2=p2->front; } }
31
15,340
struct student { char stu[100]; }a[10000]; void main() { int i,j; for(i=0;;i++) { gets(a[i].stu); if(a[i].stu[0]=='e') { a[i].stu[0]='\0'; break; } } for(j=i;j>=0;j--) { puts(a[j].stu); } }
31
15,341
struct student{ char num[20],name[20],add[100],sex[2]; int age; float score; struct student *next; }; void main() { struct student *p1,*p,*p2; p=(struct student*)malloc(sizeof(struct student)); p->next=NULL; scanf("%s",p->num); while(p->num[0]!='e') { scanf("%s%s%d%f%s",p->name,p->sex,&p->age,&p->score,p->add); p1=p; p=(struct student*)malloc(sizeof(struct student)); p->next=p1; scanf("%s",p->num); } p2=p1; while(p2!=NULL) { printf("%s %s %s %d %g %s\n",p2->num,p2->name,p2->sex,p2->age,p2->score,p2->add); p2=p2->next; } }
31
15,342
struct student { char name[50]; struct student *next; struct student *former; };//???????? void main() { struct student *head1,*head2; struct student *p1,*p2; p1=p2=(struct student*)malloc(LEN); gets(p1->name); p1->next=NULL; //???p1->next??? p1->former=NULL; head1=p1; while(strcmp(p1->name,"end")) { p2=p1; p1=(struct student*)malloc(LEN); gets(p1->name); p1->next=NULL; p1->former=p2; p2->next=p1; } p2->next=NULL; do { puts(p2->name); p2=p2->former; } while(p2!=NULL); }
31
15,343
struct stu { char num[1000]; struct stu *pre; }*phead,*p1,*p2,*pend; void print(void) { struct stu *p; for(p=pend;p!=phead;) { puts(p->num); p=p->pre; } puts(p->num); } main() { for(p1=p2=phead=(struct stu*)malloc(sizeof(struct stu));;) { gets(p1->num); if(p1->num[0]=='e') { pend=p1->pre; break; } p1=(struct stu*)malloc(sizeof(struct stu)); p1->pre=p2; p2=p1; } print(); }
31
15,344
struct stu { char num[15]; char name[20]; char gender; int age; char score[10]; char add[20]; struct stu *next; }; int n; struct stu *creat(void) { struct stu *head,*p,*q; p=q=(struct stu*)malloc(LEN); scanf ("%s%s %c %d %s%s",(*p).num,(*p).name,&(*p).gender,&(*p).age,(*p).score,(*p).add); for (n=0;(*p).gender=='f'||(*p).gender=='m';n++) { if (n==0) (*p).next=NULL; else (*p).next=q; q=p; p=(struct stu*)malloc(LEN); scanf("%s%s %c %d %s%s",(*p).num,(*p).name,&(*p).gender,&(*p).age,(*p).score,(*p).add); } head=q; return(head); } void print(struct stu *head) { struct stu *p; if (head!=NULL) for (p=head;p!=NULL;p=(*p).next) printf("%s %s %c %d %s %s\n",(*p).num,(*p).name,(*p).gender,(*p).age,(*p).score,(*p).add); } void main() { struct stu *head; head=creat(); print(head); }
31
15,345
struct student { char num[15]; char name[20]; char sex; int age; char score[10]; char add[30]; struct student *next; }; int main() { int n,i; struct student *head,*p1,*p2; n=0; p1=p2=(struct student *)malloc(LEN); p1->next=NULL; scanf("%s ",p1->num); while(strcmp(p1->num,"end")!=0) { n++; scanf("%s %c %d %s %s\n",p1->name,&p1->sex,&p1->age,p1->score,p1->add); p2=(struct student *)malloc(LEN); p2->next=p1; p1=p2; scanf("%s ",p1->num); } head=p1->next; p1=p2=head; for(i=0;i<n;i++) { printf("%s %s %c %d %s %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->add); p1=p2->next; p2=p1; } }
31
15,346
struct stu{ char num[20]; char name[20]; char gender; int age; float score; char address[20]; struct stu *next; }; struct stu *creat() { struct stu *head,*p1,*p2; head=p1=p2=(struct stu *)malloc(LEN); head->next=NULL; scanf("%s",p1->num); SCAN; for(;;) { p1=(struct stu *)malloc(LEN); scanf("%s",p1->num); if(p1->num[0]!='e') {SCAN; p1->next=p2; p2=p1;} else {break;} } return(p2); } int main() { struct stu *p,*t; t=creat(); for(p=t;p!=NULL;p=p->next) printf("%s %s %c %d %g %s\n",p->num,p->name,p->gender,p->age,p->score,p->address); }
31
15,347
int main(){ struct { char No[100]; char name[20]; char sex; int age; float grade; char address[20]; } stu[10000]; int i; cin>>stu[0].No>>stu[0].name>>stu[0].sex>>stu[0].age>>stu[0].grade>>stu[0].address; //??????? for(i=1;stu[i-1].No[0]!='e';i++){ cin>>stu[i].No; if(stu[i].No[0]!='e') //????end????? cin>>stu[i].name>>stu[i].sex>>stu[i].age>>stu[i].grade>>stu[i].address; } for(i=i-2;i>=0;i--) //???? cout<<stu[i].No<<" "<<stu[i].name<<" "<<stu[i].sex<<" "<<stu[i].age<<" "<<stu[i].grade<<" "<<stu[i].address<<endl; return 0; }
31
15,348
struct stu { char xinxi[100]; struct stu *next; }; void main() { int len=1,i; struct stu *p1,*p2,*head,*new1,*newhead; p1=p2=head=(struct stu *)malloc(sizeof(struct stu)); gets(p1->xinxi); while(strcmp(p1->xinxi,"end")!=0) { p1=(struct stu *)malloc(sizeof(struct stu)); gets(p1->xinxi); if(strcmp(p1->xinxi,"end")==0) p2->next=NULL; else { p2->next=p1; p2=p1; len++; } } p1=head; for(i=0;i<len;i++) { p2=p1=head; while(p1->next!='\0') { p2=p1; p1=p1->next; } if(i==0) { newhead=new1=p1; } else { new1=new1->next=p1; } p2->next=NULL; } p1=newhead; for(i=0;i<len;i++) { printf("%s\n",p1->xinxi); p1=p1->next; } }
31
15,349
struct student { char num[100]; struct student *next; }; int n; struct student *creat(void) { struct student *head; struct student *p1,*p2; n=0; p1=p2=(struct student*)malloc(LEN); gets(p1->num); head=NULL; while(strcmp(p1->num,"end")) { n++; p1->next=head; head=p1; p1=(struct student*)malloc(LEN); gets(p1->num); } p1->next=NULL; return(head); } void print(struct student *head) { struct student *p; p=head; if(head) do { puts(p->num); p=p->next; } while(p); } void main() { struct student *head; head=creat(); print(head); }
31
15,350
struct stru { struct stru *pre; char msg[200]; struct stru *next; }*head, *p,*q,*end; void creat() { char temp[200]; p=q=(struct stru *)malloc(LEN); head=p; head->pre=NULL; gets(p->msg); while(1) { gets(temp); if(strcmp(temp,"end")!=0) {p=(struct stru *)malloc(LEN); strcpy(p->msg,temp); p->pre=q; q->next=p; q=p;} else break; } q->next=NULL; end=q; } void print(struct stru *end) { for(p=end;p!=NULL;p=p->pre) printf("%s\n",p->msg); } void main() { creat(); print(end); }
31
15,351
struct stu { char ss[10000]; struct stu *next; }; int main() { long int i,j,k,l,m,n; struct stu *p,*p1; p1=p=(struct stu*)malloc(len); p1=null; while (1) { p=(struct stu*)malloc(len); gets(p->ss); p->next=p1; p1=p; if (strcmp(p->ss,"end\0")==0) break; } p=p->next; while (p!=null) { puts(p->ss); p=p->next; } scanf("%d",&i); }
31
15,352
struct a { struct a *back; char a[20]; char b[20]; char c; char d[20]; char e[20]; char f[20]; struct a *next; }; int main() { struct a *pHeader,*pEnd,*p1; struct a *p; pHeader=(struct a*)malloc(sizeof(struct a)); pHeader->back=NULL; p1=pHeader; for(;;) { p=(struct a*)malloc(sizeof(struct a)); scanf("%s",p->a); if(p->a[0]=='e') { pEnd=p; p->back=p1; p1->next=p; p->next=NULL; break; } p->back=p1; p1->next=p; p1=p; scanf("%s %c %s %s %s",p->b,&p->c,p->d,p->e,p->f); } printf("%s %s %c %s %s %s\n",p1->a,p1->b,p1->c,p1->d,p1->e,p1->f); free(p1->next); for(;;) { printf("%s %s %c %s %s %s\n",p1->back->a,p1->back->b,p1->back->c,p1->back->d,p1->back->e,p1->back->f); p1=p1->back; free(p1->next); if(p1->back==NULL) break; } }
31
15,353
int main() { char str[10000][100]; gets(str[0]); int i=0,j; while(str[i][0]!='e') { i++; gets(str[i]); } for(j=i-1;j>=0;j--) printf("%s\n",str[j]); getchar();getchar(); }
31
15,354
struct student { char a[100]; char b[100]; char c; int d; char e[100]; char f[100]; struct student *t; }k[1000]; int n; int main() { int i; struct student *head,*p; for(i=0;;i++) { scanf("%s",k[i].a); if(strcmp(k[i].a,"end")==0) break; scanf(" %s %c %d %s %s",k[i].b,&k[i].c,&k[i].d,k[i].e,k[i].f); if(i>0) k[i].t=&k[i-1]; if(i==0) k[i].t=NULL; } head=&k[i-1]; p=head; do{ printf("%s %s %c %d %s %s\n",p->a,p->b,p->c,p->d,p->e,p->f); p=p->t;} while(p!=NULL); return 0; }
31
15,355
struct Student { struct Student *previous; char no[20]; char name[30]; char sex; int age; float score; char address[30]; }; struct Student *creat() { struct Student *end,*p1,*p2; p1=NULL; for(;;) { p2=p1; p1=(struct Student*)malloc(LEN); p1->previous=p2; scanf("%s",p1->no); if(strcmp(p1->no,"end")==0)break; else { scanf("%s",p1->name); getchar(); p1->sex=getchar(); scanf("%d%f",&p1->age,&p1->score); scanf("%s",p1->address); } } end=p2; return(end); } void print(struct Student *end) { struct Student *p; p=end; do { printf("%s %s %c %d %g %s\n",p->no,p->name,p->sex,p->age,p->score,p->address); p=p->previous; }while(p!=NULL); } void main() { struct Student *end; end=creat(); print(end); }
31
15,356
struct student { char number[15]; char name[20]; char gender[3]; int age; float score; char address[30]; struct student *next; }; struct student *creat(void) { int i=1; struct student *head,*p1=(struct student *)malloc(LEN); head=p1; head->next=NULL; scanf("%s%s%s%d%f%s",p1->number,p1->name,p1->gender,&p1->age,&p1->score,p1->address); while(1) { p1=(struct student *)malloc(LEN); scanf("%s",p1->number); if((i=strcmp(p1->number,"end"))==0)break; scanf("%s%s%d%f%s",p1->name,p1->gender,&p1->age,&p1->score,p1->address); p1->next=head; head=p1; } return(head); } void print(struct student *p) { do{printf("%s %s %s %d %g %s\n",p->number,p->name,p->gender,p->age,p->score,p->address);p=p->next;}while(p->next!=NULL); printf("%s %s %s %d %g %s\n",p->number,p->name,p->gender,p->age,p->score,p->address); } void main() { struct student *p=creat(); print(p); }
31
15,357
struct shuju { char str[100]; struct shuju * next; }; struct shuju *create() { struct shuju *head,*p1,*p2; p1=(struct shuju* )malloc(len); gets(p1->str); p1->next=NULL; while (1) { p2=p1; p1=(struct shuju* )malloc(len); gets(p1->str); if(strcmp(p1->str,"end")==0) {free(p1);break;} p1->next=p2; } head=p2; return (head); } void print(struct shuju* head) { struct shuju* p; p=head; while (p->next!=NULL) { puts(p->str); p=p->next;} puts(p->str); } void main() { struct shuju *p; p=create(); print(p); }
31
15,358
int n; struct stu {char num[10]; char name[20]; char sex; int age; float score; char add[30]; struct stu *next; }; struct stu *create() { struct stu *head, *p1,*p2; n=1; p1=(struct stu *)malloc(LEN); scanf("%s %s %c %d %f %s", &p1->num,&p1->name,&p1->sex,&p1->age,&p1->score,&p1->add); p1->next=NULL; head = p1; p2 = p1; do { p1=(struct stu *)malloc(LEN); scanf("%s", &p1->num); if (strcmp(p1->num,"end")==0) {free(p1);break;} else { scanf(" %s %c %d %f %s",&p1->name,&p1->sex,&p1->age,&p1->score,&p1->add); p1->next=NULL; p2->next = p1; p2 = p1; n++; } }while (1); return head; } struct stu *del(struct stu *head) { struct stu *p, *ppre; p=head; while (p&&p->next!=NULL) { ppre = p; p=p->next;} printf("%s %s %c %d %g %s\n", p->num,p->name,p->sex,p->age,p->score,p->add); ppre->next=NULL; free(p); return head; } void main() { struct stu *head; int i; head=create(); for(i=0;i<n;i++) head=del(head); }
31
15,359
struct student { char num[50],ming[100]; struct student *pro; }; int n; struct student *tail; struct student *creat() { struct student *head; struct student *p1,*p2; int i; i=0; p1=p2=(struct student *)malloc(len); scanf("%s",p1->num); head=0; while (strcmp(p1->num,"end")) { gets(p1->ming); i++; if (i==1) { head=p1; head->pro=0; } else { p1->pro=p2; } p2=p1; p1=(struct student *)malloc(len); scanf("%s",p1->num); } tail=p2; return(tail); } main() { struct student *p; creat(); p=tail; for (;p!=0;) { printf("%s%s\n",p->num,p->ming); p=p->pro; } }
31
15,360
struct student { char num[10]; char name[30]; char sex[2]; char age[5]; char score[10]; char add[20]; struct student *prev; }; struct student *create(void) { struct student *p1,*p2; p1=(struct student *)malloc(sizeof(struct student)); scanf("%s",p1->num); if(strcmp(p1->num,"end")) { scanf("%s%s%s%s%s",p1->name,p1->sex,p1->age,p1->score,p1->add); p2=p1; p1->prev=NULL; } while(strcmp(p1->num,"end")) { p1=(struct student *)malloc(sizeof(struct student)); scanf("%s",p1->num); if(strcmp(p1->num,"end")) { scanf("%s%s%s%s%s",p1->name,p1->sex,p1->age,p1->score,p1->add); p1->prev=p2; p2=p1; } } return(p2); } void main() { struct student *p1; p1=create(); while(p1!=NULL) { printf("%s %s %s %s %s %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->add); p1=p1->prev; } }
31
15,361
struct student{ char num[20]; char name[20]; char sex; int age; float score; char address[20]; struct student *next; }; int n; struct student *create() { struct student *head; struct student *p1,*p2; head=NULL; n=0; p1=p2=(struct student *)malloc(len); scanf("%s",p1->num); if(p1->num[0]=='e') return(head); scanf("%s %c %d%f %s",p1->name,&p1->sex,&p1->age,&p1->score,p1->address); //printf("%s %s %c %d%d %s",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->address); while(n!=-1) { n++; if(n==1) p1->next=NULL; else p1->next=p2; p2=p1; p1=(struct student *)malloc(len); scanf("%s",p1->num); if(p1->num[0]=='e') break; scanf("%s %c %d%f %s",p1->name,&p1->sex,&p1->age,&p1->score,p1->address); //printf("%s %s %c %d%d %s",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->address); } head=p2; return(head); } void print(struct student *p) { while(p!=NULL) { printf("%s %s %c %d %g %s\n",p->num,p->name,p->sex,p->age,p->score,p->address); p=p->next; } } void main() { struct student *p; p=create(); print(p); }
31
15,362
int n; struct student { char a[30]; char name[20]; char sex[20]; char age[20]; char score[20]; char addr[30]; struct student *next; } *creat(void) { struct student *head; struct student *p1,*p2; n=0; p1=p2=(struct student*) malloc(len); scanf("%s%s%s%s%s%s",p1->a,p1->name,p1->sex,p1->age,p1->score,p1->addr); head=NULL; while(strcmp(p1->a,"end")!=0) { n++; if (n==1) p1->next=NULL; else p1->next=p2; head=p1; p2=p1; p1=(struct student*)malloc(len); scanf("%s%s%s%s%s%s",p1->a,p1->name,p1->sex,p1->age,p1->score,p1->addr); } return(head); } void print(struct student*head) { struct student *p1; p1=head; if(head!=NULL) do { printf("%s %s %s %s %s %s\n",p1->a,p1->name,p1->sex,p1->age,p1->score,p1->addr); p1=p1->next; }while(p1!=NULL); } main() { struct student *head; head=creat(); print(head); }
31
15,363
struct stu { char num[9]; char name[18]; char sex[2]; int age; float score; char addr[12]; struct stu *pre; }; struct stu *create() { struct stu *head,*p1,*p2; char end[]={"end"}; p1=(struct stu *)malloc(LEN); scanf("%s",p1->num); if(strcmp(p1->num,end)==0) { return p1; } scanf("%s%s%d%f%s",p1->name,p1->sex,&p1->age,&p1->score,p1->addr); p1->pre=NULL; p2=p1; while(1) { p1=(struct stu *)malloc(LEN); scanf("%s",p1->num); if(strcmp(p1->num,end)==0) { return p2; } scanf("%s%s%d%f%s",p1->name,p1->sex,&p1->age,&p1->score,p1->addr); p1->pre=p2; p2=p1; } } void print(struct stu *head) { struct stu *p1; p1=head; while(p1) { printf("%s %s %s %d %g %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->addr); p1=p1->pre; } } void destroy(struct stu *head) { struct stu *p1; while(head) { p1=head; head=p1->pre; free(p1); } } int main() { struct stu *head; head=create(); print(head); destroy(head); return 0; }
31
15,364
struct student { char num[200]; struct student *next; }; void main() { int n,i,k,j; struct student *head; struct student *p1,*p2; struct student *newhead,*nnew; n=0; p1=p2=(struct student *)malloc(sizeof(struct student)); gets(p1->num); head=NULL; while(strcmp(p1->num,"end")!=0) { n=n+1; if(n==1) head=p1; else p2->next=p1; p2=p1; p1=(struct student *)malloc(sizeof(struct student)); gets(p1->num); } p2->next=NULL; for(i=0;i<n;i++) { p2=p1=head; while(p1->next!=NULL) { p2=p1; p1=p1->next; } if(i==0) newhead=nnew=p1; else nnew=nnew->next=p1; p2->next=NULL; } p1=newhead; for(i=0;i<n;i++) { printf("%s",p1->num); p1=p1->next; printf("\n"); } }
31
15,365
struct stu {char num[50]; char name[50]; char sex[1]; int age; char score[50]; char add[50]; struct stu *next; }; int main() {struct stu *head,*p1,*p2; p1=(struct stu*)malloc(LN); scanf("%s",p1->num); scanf("%s",p1->name); scanf("%s",p1->sex); scanf("%d",&p1->age); scanf("%s",p1->score); scanf("%s", p1->add); p1->next=NULL; p2=p1;head=p1; do { p1=(struct stu*)malloc(LN); scanf("%s",p1->num); if(*(p1->num)=='e') {free(p1);head=p2;break;} else { scanf("%s",p1->name); scanf("%s",p1->sex); scanf("%d",&p1->age); scanf("%s",p1->score); scanf("%s", p1->add); p1->next=p2; p2=p1; } }while(1); while(head) {printf("%s %s %c %d %s %s\n",head->num,head->name,*(head->sex),head->age,head->score,head->add); head=head->next; } }
31
15,366
struct st { char id[200]; struct st *pre; struct st *next; } *p1, *p2; int main(void) { p1 = p2 = (struct st*)malloc(LEN); p1->pre = NULL; gets(p1->id); while(strcmp(p1->id,"end")) { p2->next=p1; p2=p1; p1=(struct st*)malloc(LEN); gets(p1->id); p1->pre=p2; } while(p2!=NULL) { printf("%s\n",p2->id); p2 = p2->pre; } return 0; }
31
15,367
struct Student { char no[10]; char name[20]; char sex; int age; char score[7]; char add[15]; struct Student *next; }; int main() { struct Student *p[1000],*head; int i; for(i=0; ;i++) { p[i]=(struct Student *)malloc(LEN); scanf("%s",p[i]->no); if(strcmp(p[i]->no,"end")==0) { head=p[i-1];//head???? break;//???end??? } else { getchar(); scanf("%s %c %d %s %s",p[i]->name,&p[i]->sex,&p[i]->age,p[i]->score,p[i]->add); getchar(); if(i==0) { p[i]->next=NULL;//???????????????????? } else { p[i]->next=p[i-1];//???????????????? } } } for(head=head;head!=NULL;head=head->next) { printf("%s %s %c %d %s %s\n",head->no,head->name,head->sex,head->age,head->score,head->add); } return 0; }
31
15,368
struct student { char info[50]; struct student *p; }; void main() { int m,n,i,j; struct student *p,*head; for(i=0;;i++) { p=DT; if(i==0) p->p=NULL; gets(p->info); if(strcmp(p->info,"end")==0) break; p->p=head; head=p; } for(p=head,j=0;j<i;j++,p=p->p) { puts(p->info); } }
31
15,369
void main() { struct student{ char a[20]; char b[20]; char c; int d; float e; char f[20]; struct student *next; }; struct student *head,*p1,*p0;int n=0; p1=(struct student*) malloc(LEN); scanf("%s",p1->a); head=p1; p1->next=0; while(strcmp(head->a,"end")!=0) { n++; if(n>1) p1=p0; scanf("%s %c %d %f %s",head->b,&head->c,&head->d,&head->e,head->f); p0=(struct student*) malloc(LEN); head=p0; p0->next=p1; scanf("%s",p0->a); } head=p1; for(p1=head;(p1!=0)&&(strcmp(p1->a,"end")!=0);) { printf("%s %s %c %d %g %s\n",p1->a,p1->b,p1->c,p1->d,p1->e,p1->f); p1=p1->next; } }
31
15,370
int i,n,m,t; struct stu { char num[1000]; struct stu *next; }; struct stu *creat(void) { struct stu *head; struct stu *p1,*p2; n=0; p1=p2=(struct stu *)malloc(len); gets(p1->num); while(strcmp(p1->num,"end")!=0) { n=n+1; if(n==1) head=p1; else p2->next=p1; p2=p1; p1=(struct stu *)malloc(len); gets(p1->num); } p2->next=NULL; return (head); } void print(struct stu *head) { struct stu *p1,*p2; m=n; t=n; for(i=1;n>0;i++) { while(n>0) { if(n==t) p2=p1=head; else p2=p1; p1=p1->next; n=n-1; } printf("%s\n",p2->num); n=m-i; t=n; } } void main() { struct stu *head; head=creat(); print(head); }
31
15,371
struct student { char number[20]; char name[20]; char sex; int age; float grade; char address[20]; struct student *next; }; int n; struct student *creat(void) { struct student *head,*p1,*p2; head=p1=p2=(struct student *)malloc(LEN); scanf("%s %s %c %d %f %s",p1->number,p1->name,&p1->sex,&p1->age,&p1->grade,p1->address); p2->next=NULL; for(n=0;;n++) { p1=(struct student *)malloc(LEN); p1->next=p2; scanf("%s",p1->number); if(strcmp(p1->number,"end")==0)break; scanf("%s %c %d %f %s",p1->name,&p1->sex,&p1->age,&p1->grade,p1->address); p2=p1; head=p1; }return head; } void main() { struct student *head,*p; head=creat(); p=head; while(p!=NULL) { printf("%s %s %c %d %g %s\n",p->number,p->name,p->sex,p->age,p->grade,p->address); p=p->next; } }
31
15,372
struct student { char num[10]; char name[20]; char sex[2]; int age; char score[30]; char add[30]; struct student *next; }; int main() { struct student *head; struct student *p1,*p2,*p; p2=p=(struct student*)malloc(sizeof(struct student)); scanf("%s%s%s%d%s%s",p2->num,p2->name,p2->sex,&p2->age,p2->score,p2->add); p2->next=NULL; do { p2=(struct student*)malloc(sizeof(struct student)); scanf("%s",p2->num); if(strcmp(p2->num,"end")==0) break; scanf("%s%s%d%s%s",p2->name,p2->sex,&p2->age,&p2->score,p2->add); p2->next=p; p=p2; } while(strcmp(p2->num,"end")!=0); head=p; for(p1=head;p1!=NULL;p1=p1->next) { printf("%s %s %s %d %s %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->add); } return 0; }
31
15,373
struct Student { char id[10]; char name[100]; char sex; char year[10]; char mark[10]; char ad[20]; }stu[1000]; int main() { int i,k=0; for(i=0;;i++) { scanf("%s ",stu[i].id); if(stu[i].id[0]=='e') {break;} else {scanf("%s %c %s %s %s\n",stu[i].name,&stu[i].sex,stu[i].year,stu[i].mark,stu[i].ad); k++;} } for(i=k-1;i>=0;i--) printf("%s %s %c %s %s %s\n",stu[i].id,stu[i].name,stu[i].sex,stu[i].year,stu[i].mark,stu[i].ad); }
31
15,374
struct student { char id[15]; char name[20]; char sex; int age; char grade[20]; char add[20]; struct student *next; }; struct student *set(void) { struct student *head,*p1,*p2; head=(struct student *)malloc(LEN); p1=head; p2=head; scanf("%s%s %c %d %s %s",head->id,head->name,&head->sex,&head->age,head->grade,head->add); p1=(struct student *)malloc(LEN); scanf("%s%s %c %d %s %s",p1->id,p1->name,&p1->sex,&p1->age,p1->grade,p1->add); p2->next=p1; p2=p1; while(1) { p1=(struct student *)malloc(LEN); scanf("%s",p1->id); if(strcmp(p1->id,"end")==0) { p2->next=NULL; break; } scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->grade,p1->add); p2->next=p1; p2=p1; } return(head); } int main() { struct student *p,*p1,*p2,*p3; int i,j,n=1; p=set(); p1=p;p1=p1->next;p1=p1->next; p2=p;p2=p2->next; p3=p; while(p1!=NULL) { p2->next=p3; p3=p2;p2=p1;p1=p1->next; } p2->next=p3; //????????????????p2???? p->next=NULL; //???????p?????? p1=p2; //?p1??????????????????? while(p1!=NULL) { printf("%s %s %c %d %s %s\n",p1->id,p1->name,p1->sex,p1->age,p1->grade,p1->add); p1=p1->next; } return 0; }
31
15,375
char str[]={"end"}; struct student { char num[100]; char name[100]; char sex; int age; char score[100000]; char add[100]; struct student *next; }; struct student *create() { struct student *head,*p1,*p2; p1=(struct student*)malloc(Len); scanf("%s %s %c %d %s %s",p1->num,p1->name,&p1->sex,&p1->age,p1->score,p1->add); p1->next=NULL; p2=p1; p1=(struct student*)malloc(Len); for(;;) {scanf("%s",p1->num); if(!strcmp(p1->num,str)) break; else { scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->add); p1->next=p2; p2=p1; p1=(struct student*)malloc(Len); } } head=p2;return(head); } void main() { struct student *p; p=create(); do {printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->add); p=p->next; }while(p!=NULL); }
31
15,376
struct student { char s[100]; struct student *next; }; struct student *creat() { struct student *head,*p1,*p2; p1=(struct student *)malloc(len); gets(p1->s); p1->next=null; do { p2=(struct student *)malloc(len); gets(p2->s); p2->next=p1; p1=p2; } while(strcmp(p2->s,"end")); head=p2; return(head); } void main() { struct student *p,*head; head=creat(); p=head; while(p->next){ p=p->next; printf("%s\n",p->s); } }
31
15,377
struct student { char number[10]; char name[100]; char sex; int age; char score[20]; char add[20]; struct student *pre; }; int n; struct student *creat(void) { struct student *tail; struct student *p1,*p2; n=0; p1=p2=(struct student *)malloc(sizeof(struct student)); scanf("%s %s %c %d %s %s",p1->number,p1->name,&p1->sex,&p1->age,p1->score,p1->add); p1->pre=NULL; while(1) { n++; tail=p1; p1=(struct student *)malloc(sizeof(struct student)); scanf("%s",p1->number); if(strcmp(p1->number,"end")==0) break; scanf("%s %c %d %s %s",p1->name,&p1->sex,&p1->age,p1->score,p1->add); p1->pre=p2; p2=p1; } return(tail); } void print(struct student *tail) { struct student *p; p=tail; do { printf("%s %s %c %d %s %s\n",p->number,p->name,p->sex,p->age,p->score,p->add); p=p->pre; }while(p!=NULL); } void main() { print(creat()); }
31
15,378
struct student { char s[10]; char name[30]; char sex; char age[3]; char score[6]; char place[15]; struct student *next; struct student *last; }; int n; struct student *creat() { struct student *head1,*head2; struct student *p1,*p2; n=0; p1=p2=(struct student*)malloc(100); head1=NULL;scanf("%s ",&p1->s); do { scanf("%s %c %s %s %s",&p1->name,&p1->sex,&p1->age,&p1->score,&p1->place); n=n+1; if(n==1) {head1=p1;p1->last=NULL;} else {p2->next=p1;p1->last=p2; p2=p1;}p1=(struct student*)malloc(100);scanf("%s",&p1->s); }while(p1->s[0]!='e');head2=p2; p2->next=NULL; return(head2); } void main() { struct student *p1; p1=creat(); do{printf("%s %s %c %s %s %s\n",p1->s,p1->name,p1->sex,p1->age,p1->score,p1->place); p1=p1->last; }while(p1!=NULL); }
31
15,379
struct student { char num[20]; char name[20]; char sex; int age; char grade[20]; char address[20]; struct student *next; }; struct student stud[200]; struct student * input() { struct student *head,*p; head=NULL; p=(struct student *)malloc(LEN); scanf("%s",p->num); while(strcmp(p->num,"end")!=0) { scanf("%s %c %d %s %s",p->name,&p->sex,&p->age,p->grade,p->address); p->next=head; head=p; p=(struct student *)malloc(LEN); scanf("%s",p->num); } return(head); } void output(struct student *head) { struct student *p; p=head; while(p!=NULL) { printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->grade,p->address); p=p->next; } } main() { struct student *head; head=input(); output(head); return 0; }
31
15,380
struct student //????? { char id[10]; char name[20]; char gender; int age; char score[10]; char address[20]; struct student *next, *up;//next?????????,up??????????????????? }; int main() { struct student *head, *tail, *p, *r,*q; p=r=head=(struct student *)malloc(len);//head??????? p->up=NULL;//??????up????null??????????up?????????????? do { scanf("%s",p->id); if(strcmp(p->id,"end")!=0)//???????end?????????? { scanf("%s %c %d %s %s",p->name,&p->gender,&p->age,p->score,p->address); p->next=r=(struct student *)malloc(len);//??????next???????up??????? r->up=p; p=r; } else { p->next=NULL;//?????? tail=p->up;//?tail????????????????up??????????? break; } }while(1); q=tail; do { printf("%s %s %c %d %s %s\n",q->id,q->name,q->gender,q->age,q->score,q->address);//?up????? q=q->up; }while(q!=NULL); return 0; }
31
15,381
int n; struct student{char stu[50];struct student *next;}; struct student *creat(void) { struct student *head; struct student *p1,*p2; n=0; p1=p2=(struct student*)malloc(LEN); gets(p1->stu); head=NULL; while(strcmp(p1->stu,"end")!=0) { n=n+1; if(n==1)head=p1; else p2-> next=p1; p2=p1; p1=(struct student*)malloc(LEN); gets(p1->stu); } p2-> next=NULL; return(head); } struct student *reverse(struct student *head) { struct student *p1,*p2,*p3; p2=head;p3=head->next; do { p1=p2;p2=p3;p3=p2->next;p2->next=p1; }while(p3!=NULL); head->next=NULL; return(p2); } void print(struct student *head) { struct student *p; p=head; if(head!=NULL) while(p) { if(p->stu!="end") printf("%s\n",p->stu); p=p->next; } } int main() { struct student *head; head=creat(); head=reverse(head); print(head); return 0; }
31
15,382
main() { struct a { char s[100]; struct a *next; }; int len=sizeof(struct a),n=0; struct a *p1,*p2,*head,*p; p1=p2=(struct a *)malloc(len); head=NULL; gets(p1->s); while(strcmp(p1->s,"end")!=0) { n++; if(n==1) head=p1; else p1->next=p2; p2=p1; p1=(struct a *)malloc(len); gets(p1->s); } head->next=NULL; p=p2; if(head!=NULL) { do { puts(p->s); p=p->next; }while(p!=NULL); } }
31
15,383
struct student { char num[20]; char name[20]; char sex; int age; char score[20]; char adress[20]; struct student *next; }; int n; struct student *input(void) { struct student *p,*q,*head; int n=0; p=q=(struct student *)malloc(sizeof(struct student)); scanf("%s %s %c %d %s %s\n",p->num,p->name,&p->sex,&p->age,p->score,p->adress); head=null; while(strcmp(p->num,"end")!=0) { n=n+1; if(n==1) { head=p; } else { q->next=p; } q=p; p=(struct student*)malloc(sizeof(struct student)); scanf("%s %s %c %d %s %s\n",p->num,p->name,&p->sex,&p->age,p->score,p->adress); } q->next=null; return(head); } void output(struct student *head) { struct student *p; p=head; if(head!=null) do { printf("%s %s %c %d %s %s\n",p->num,p->name,p->sex,p->age,p->score,p->adress); p=p->next; } while(p!=null); } struct student *exchange(struct student * head) { struct student *p,*q,* n,* nhead=null; do{ q=null; p=head; while(p->next!=null) { q=p; p=p->next; } if(nhead==null) { nhead=p; n=nhead->next=q; } n=n->next=q; q->next=null; }while(head->next!=null); return(nhead); } int main() { struct student *input(void); struct student *exchange(struct student *); void output(struct student *); struct student *a,*b; a=input();//??input???????a b=exchange(a); output(b); return 0; }
31
15,384
struct stu { char xh[10]; char name[20]; char xb; int age; char score[20]; char add[20]; struct stu *next; }; struct stu *creat() { struct stu *head,*p1,*p2; int n=0; p1=p2=(struct stu *)malloc(sizeof (struct stu)); head=0; while(strcmp(p1->xh,"end")!=0) { n++; if(n==1) { p1->next=0; head=p1; } else { p2=p1; p1=(struct stu *)malloc(sizeof (struct stu)); p1->next=p2; } scanf("%s",&p1->xh); if(strcmp(p1->xh,"end")==0) { head=p2; break; } scanf(" %s %c %d %s %s",&p1->name,&p1->xb,&p1->age,&p1->score,&p1->add); } return (head); } void print(struct stu *head) { struct stu *p; p=head; while (p!=0) { printf("%s %s %c %d %s %s\n",p->xh,p->name,p->xb,p->age,p->score,p->add); p=p->next; } } void main() { struct stu *head; head=creat(); print(head); }
31
15,385
struct stu { char num[20]; char name[30]; char sex; int age; float score; char add[30]; struct stu *next; }; void main() { int i,len=1; struct stu *p1,*p2,*head,*new,*newhead; p1=p2=head=(struct stu*)malloc(sizeof(struct stu)); printf("\n"); scanf("%s %s %c %d %f %s" ,p1->num,p1->name,&p1->sex,&p1->age,&p1->score,p1->add); while(strcmp(p1->num,"end")!=0) {p1=(struct stu*)malloc(sizeof(struct stu)); scanf("%s %s %c %d %f %s" ,p1->num,p1->name,&p1->sex,&p1->age,&p1->score,p1->add); printf("\n"); if(strcmp(p1->num,"end")==0) p2->next=NULL; else {p2->next=p1; p2=p1; len++;} } p1=head; for(i=0;i<len;i++) { p1=p2=head; while(p1->next!=NULL) {p2=p1; p1=p1->next; } if(i==0) newhead=new=p1; else new=new->next=p1; p2->next=NULL; } p1=newhead; for(i=0;i<len;i++) {printf("%s %s %c %d %g %s\n",p1->num,p1->name,p1->sex,p1->age,p1->score,p1->add); p1=p1->next; } }
31
15,386
struct student { char ID[10]; char name[20],s; int age; char score[10]; char ad[20]; struct student *next; }; int main() { struct student *head; int n,i,j; n=0; head = NULL; struct student *p1 ; while (1) { p1 = (struct student *)malloc(len); scanf("%s" , p1 -> ID); if (p1 -> ID[0] == 'e' && p1 -> ID[1] == 'n' && p1 -> ID[2] == 'd' ) break; scanf(" %s %c %d %s %s",p1->name,&p1->s,&p1->age,p1->score,p1->ad); n++; p1 -> next = head; head = p1; } p1 = head; while (p1 != NULL) { printf("%s %s %c %d %s %s\n",p1->ID,p1->name,p1->s,p1->age,p1->score,p1->ad); p1 = p1 -> next; } }
31
15,387
struct student{char xh[20];char name[50];char sex;int age;char gra[10];char adds[50];struct student *next;}; void main() { struct student *pa,*pb; int i; pa=pb=(struct student*)malloc(l); for(i=0; ;i++) { scanf("%s",pa->xh); if(pa->xh[0]=='e') break; scanf("%s %c %d %s %s",pa->name,&pa->sex,&pa->age,pa->gra,pa->adds); if(i==0) {pa->next=NULL;} else pa->next=pb; pb=pa; pa=(struct student*)malloc(l); } while(pb!=NULL) {printf("%s %s %c %d %s %s\n",pb->xh,pb->name,pb->sex,pb->age,pb->gra,pb->adds);pb=pb->next;} }
31
15,388
struct student { char a[20]; char b[40]; char c; int d; float e; char f[20]; struct student*before; }; int n; struct student* hh() { struct student*p1,*p2,*head;n=0; p1=p2=(struct student*)malloc(LEN); scanf("%s ",&p1->a);head=NULL; while(strcmp(p1->a,"end")) { scanf("%s %c %d %f %s ",&p1->b,&p1->c,&p1->d,&p1->e,&p1->f); n=n+1; if(n==1) p1->before=NULL; else p1->before=p2; p2=p1; p1=(struct student*)malloc(LEN); scanf("%s ",&p1->a); }; head=p2; return(head); } void main() { struct student*p; p=hh(); while(p!=NULL) { printf("%s %s %c %d %g %s\n",p->a,p->b,p->c,p->d,p->e,p->f); p=p->before; }; }
31
15,389
struct student { char num[20]; char name[20]; char sex; int age; float grade; char addr[100]; struct student *next; }; struct student *creat() { struct student *pt,*pn; pn=(struct student *)malloc(sizeof(struct student)); pt=0; scanf("%s",pn->num); pn->next=0; while(pn->num[0]!='e') { scanf("%s %c %d %f %s",pn->name,&pn->sex,&pn->age,&pn->grade,pn->addr); pt=pn; pn=(struct student *)malloc(sizeof(struct student)); pn->next=pt; scanf("%s",pn->num); } return(pt); } int main() { struct student *head,*p; head=creat(); p=head; while(p!=0) { printf("%s %s %c %d %g %s\n",p->num,p->name,p->sex,p->age,p->grade,p->addr); p=p->next; } return 0; }
31
15,390
/* ????? ?????????????????????????? ???????????????????????? ????????????????????????????????????????????????????? */ //???struct Student??????????????? typedef struct Stu{ char stu_id[20]; //?? char name[20]; //?? char gender; //?? int age; //?? char score[20]; //?? char address[50]; //?? struct Student* next; //??? struct Student* prev; //??? }Student; int main() { char start[50]; Student* head = NULL; //?????????? Student* tail = NULL; //?????????? //????????????? while(scanf("%s",start)) //????????????? { if(strcmp(start,"end") != 0) //?????????end, ????????????????????????????????? { Student *stu = (Student*)malloc(sizeof(Student)); //?????????????? strcpy(stu->stu_id,start); //????? if(scanf(" %s %c %d %s %s",stu->name,&stu->gender,&stu->age,stu->score,stu->address)) //?????? { //????????????????? stu->next = NULL; stu->prev = NULL; if(head == NULL) //?????????????????head????tail??? { head = stu; tail = stu; } else //????????????????????tail?next??????????????tail, ????tail??? { tail->next = stu; stu->prev = tail; tail = tail->next; } } } else // ???????????end, ????? break; } //?????????????????????? while(tail != NULL) { printf("%s %s %c %d %s %s\n",tail->stu_id,tail->name,tail->gender,tail->age,tail->score,tail->address); //?????? head = tail; tail = tail->prev; //??????????? free(head); } return 0; }
31
15,391
struct people { char num[20]; char name[20]; char sex; char age[5]; char score[10]; char address[30]; }; struct people child[1000]; void main() { int i; for(i=0;;i++) { scanf("%s",child[i].num); if (strcmp(child[i].num,"end")==0) break; scanf("%s %c%s%s%s",child[i].name,&child[i].sex,child[i].age,child[i].score,child[i].address); } for(i--;i>=0;i--) { printf("%s %s %c %s %s %s\n",child[i].num,child[i].name,child[i].sex,child[i].age,child[i].score,child[i].address); } }
31
15,392
struct Stu { char stu[100]; struct Stu *link; }; int main() { struct Stu *p1,*p2; p2=p1=(struct Stu *)malloc(LEN); gets(p1->stu); p1->link=NULL; for(;;) { p2=p1; p1=(struct Stu *)malloc(LEN); gets(p1->stu); p1->link=p2; if(strcmp(p1->stu,"end")==0) break; } for(;;) { puts(p2->stu); p2=p2->link; if(p2==NULL) break; } return 0; }
31
15,393
struct student {char a[88]; struct student *next; }; struct student *creat(void) {struct student *p1,*p2,*head; p1=p2=(struct student *)malloc(LEN); gets(p1->a); p1->next=0; while(strcmp(p1->a,"end")!=0) {p2=p1; p1=(struct student *)malloc(LEN); gets(p1->a); p1->next=p2; } head=p2; return(head); } void print(struct student *head) {struct student *p; p=head; while(p!=0) {puts(p->a); p=p->next;} } void main() {struct student *head; head=creat(); print(head); }
31
15,394
struct student { char num[10]; char name[30]; char gender; int age; char score[10]; char address[30]; struct student *before; }; void main () { struct student stu[1000], *tail, *p; int i=0,j; while (scanf ("%s %s %c %d %s %s",&stu[i].num, &stu[i].name, &stu[i].gender, &stu[i].age, &stu[i].score, &stu[i].address)!=EOF) i++; // for (i=0;stu[i].num[0]!='e';i++) // { // scanf ("%s %s %c %d %d %s",stu[i].num, stu[i].name, // &stu[i].gender, &stu[i].age, &stu[i].score, stu[i].address); // } tail=&stu[i-1]; for (j=i-1;j>=0;j--) stu[j].before=&stu[j-1]; stu[0].before=0; p=tail->before; do { printf ("%s %s %c %d %s %s\n",p->num, p->name, p->gender, p->age, p->score, p->address); p=p->before; } while (p!=0); }
31
15,395
void main() { struct student { char stu[100]; struct student *next; struct student *prev; }*head,*p1,*p2,*p; int n; p1=p2=(struct student *)malloc(LEN); gets(p1->stu); p1->prev=NULL; while(strcmp(p1->stu,"end")!=0) { p1=(struct student*)malloc(LEN); p1->prev=p2; gets(p1->stu); p2->next=p1; p2=p1; } p2->next=NULL; p=p2; do { p=p->prev; printf("%s\n",p->stu); }while(p->prev!=NULL); }
31
15,396
struct student { char stuID[20]; char name[20]; char sex; int age; char score[10]; char add[20]; struct student*next; }; int main() { struct student *p,*a; char str[10]={"end"}; p=(struct student*)malloc(sizeof(struct student)); scanf("%s",p->stuID); p->next=NULL; while(strcmp(p->stuID,str)!=0) { scanf("%s %c %d %s %s",p->name,&(p->sex),&(p->age),p->score,p->add); a=p; p=(struct student*)malloc(sizeof(struct student)); p->next=a; scanf("%s",p->stuID); } while(p->next!=NULL) { p=p->next; printf("%s %s %c %d %s %s\n",p->stuID,p->name,p->sex,p->age,p->score,p->add); } return 0; }
31
15,397
struct stu { struct stu *back; char info[number]; struct stu *next; } main() { char infos[number]; char s[]="end"; struct stu *head,*p1,*p2,*tail; gets(infos); p2=(struct stu *)malloc(Len); if (strcmp(infos,s)!=0) { head=p2; p2->back=NULL; strcpy(p2->info,infos); p2->next=NULL; gets(infos); p1=p2; } while(strcmp(infos,s)!=0) { p2=(struct stu *)malloc(Len); p1->next=p2; p2->back=p1; strcpy(p2->info,infos); p2->next=NULL; p1=p2; gets(infos); } tail=p1; while(p1) { printf("%s\n",p1->info); p1=p1->back; } }
31
15,398
struct student { char str[100]; struct student *next; }; int n; struct student *creat(void) { struct student *head; struct student *p1,*p2; p1=p2=(struct student *)malloc(LEN); gets(p1->str); p1->next=NULL; p2=p1; while(strcmp(p2->str,"end")!=0) { n=n+1; if(n==1)head=p1; else {head=p2;p1=p2;} p2=(struct student *)malloc(LEN); p2->next=p1; gets(p2->str); } return(head); } void print(struct student *head) { struct student *p; p=head; if(head!=NULL) while(p->next!=NULL) { puts(p->str); p=p->next; } puts(p->str); } void main() { struct student *ip; ip=creat(); print(ip); }
31
15,399
struct Student { char num[41]; char name[41]; char gender[5]; int age; char score[10]; char address[41]; struct Student * next; struct Student * pre; }; int size=sizeof(struct Student); struct Student gan; void push () { char ster[41];struct Student * pt; scanf("%s",ster); while(strcmp(ster,"end")!=0) { pt=malloc(size); strcpy(pt->num,ster); scanf("%s %s %d %s %s",pt->name,pt->gender,&pt->age,pt->score,pt->address); (gan.pre)->next=pt;//????????????next? pt->pre=gan.pre;//????????????pre? gan.pre=pt;//?????????????? pt->next=&gan;//??????? scanf("%s",ster); } } void display(struct Student stu) { printf("%s %s %s %d %s %s\n",stu.num,stu.name,stu.gender,stu.age,stu.score,stu.address); } int main() { gan.next=&gan; gan.pre=&gan; push(); struct Student * pt; pt=gan.pre; while(pt!=&gan) { display(*pt); pt=pt->pre; } return 0; }
31