We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#include<stdio.h> #include<stdlib.h> struct Student{ int num; char name[20]; struct Student *next; }; struct Student *creat() { struct Student *head = NULL,*end,*pnew; pnew=(struct Student*)malloc(sizeof(struct Student)); printf("请输入学号"); scanf("%d",&pnew->num); printf("请输入姓名"); scanf("%s",&pnew->name); int count = 0; while(pnew->num != 0) { count ++; if(1 == count) { pnew->next = head; head = pnew; end = pnew; } else { end->next = pnew; end = pnew; } pnew = (struct Student*)malloc(sizeof(struct Student)); scanf("%d",&pnew->num); scanf("%s",&pnew->name); } end->next = NULL; free(pnew); return (head); } struct Student *reserve(struct Student *head) { struct Student *p,*pnew = NULL; if(head == NULL && head->next == NULL) { return head; } p = head; while(p != NULL) { struct Student *temp = p->next; p->next = pnew; pnew = p; p = temp; } return (pnew); } void print(struct Student *head) { struct Student *p; p = head; while(p != NULL) { printf("请输入学号"); scanf("%d",&pnew->num); printf("请输入姓名"); printf("姓名%s\n",p->name); p = p->next; } } int main() { struct Student *pt; pt = creat(); pt = reserve(pt); print(pt); system("pause"); return 0; } `
The text was updated successfully, but these errors were encountered:
Sorry, something went wrong.
No branches or pull requests
The text was updated successfully, but these errors were encountered: