{"action":"created","issue":{"url":"https://api.github.com/repos/android-nuc/18-C-Train/issues/28","repository_url":"https://api.github.com/repos/android-nuc/18-C-Train","labels_url":"https://api.github.com/repos/android-nuc/18-C-Train/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/android-nuc/18-C-Train/issues/28/comments","events_url":"https://api.github.com/repos/android-nuc/18-C-Train/issues/28/events","html_url":"https://github.com/android-nuc/18-C-Train/issues/28","id":385580067,"node_id":"MDU6SXNzdWUzODU1ODAwNjc=","number":28,"title":"张焱梁 链表倒序 宿舍管理（未做文件）","user":{"login":"yanlianga","id":44320787,"node_id":"MDQ6VXNlcjQ0MzIwNzg3","avatar_url":"https://avatars3.githubusercontent.com/u/44320787?v=4","gravatar_id":"","url":"https://api.github.com/users/yanlianga","html_url":"https://github.com/yanlianga","followers_url":"https://api.github.com/users/yanlianga/followers","following_url":"https://api.github.com/users/yanlianga/following{/other_user}","gists_url":"https://api.github.com/users/yanlianga/gists{/gist_id}","starred_url":"https://api.github.com/users/yanlianga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yanlianga/subscriptions","organizations_url":"https://api.github.com/users/yanlianga/orgs","repos_url":"https://api.github.com/users/yanlianga/repos","events_url":"https://api.github.com/users/yanlianga/events{/privacy}","received_events_url":"https://api.github.com/users/yanlianga/received_events","type":"User","site_admin":false},"labels":[{"id":1153753184,"node_id":"MDU6TGFiZWwxMTUzNzUzMTg0","url":"https://api.github.com/repos/android-nuc/18-C-Train/labels/%E4%BF%AE%E6%94%B9","name":"修改","color":"FF69B4","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-11-29T05:49:26Z","updated_at":"2018-12-08T02:02:12Z","closed_at":null,"author_association":"NONE","body":"# 链表倒序\r\n```c\r\n#include<stdio.h>\r\n#include<stdlib.h>\r\n#define LEN sizeof(struct re)\r\nstruct re\r\n{\r\n\tchar ch;\r\n\tstruct re * next;\r\n};\r\n\r\n//创建链表 \r\nstruct re * creat(int n)\r\n{\r\n\tint i;\r\n\tstruct re * head, * pp,* p;\r\n\thead=NULL;  \r\n\tpp=p=(struct re*) malloc(LEN);\r\n\tif(p!=NULL)\r\n\t{\r\n\t\tscanf(\"%d\",&p->ch);\r\n\t\thead=p;\r\n\t\tpp=p;\r\n\t}\r\n\tfor(i=1;i<n;i++)\r\n\t{\r\n\t\tp=(struct re*)malloc(LEN);\r\n\t\tif(p!=NULL)\r\n\t\t{\r\n\t\t\tscanf(\"%d\",&p->ch);\r\n\t\t\tpp->next=p;\r\n\t\t\tpp=p;\r\n\t\t}\r\n\t}\r\n\tp->next=NULL;\r\n\treturn head; \r\n}\r\nstruct re *reverse(struct re *head)\r\n{\r\n\tstruct re *p=head,*q;\r\n\thead=NULL;\r\n\twhile(p)\r\n\t{\r\n\t\tq=p;\r\n\t\tp=p->next;\r\n\t\tq->next=head;\r\n\t\thead=q;\r\n\t}\r\n\treturn head;\r\n}\r\n\r\nvoid print(struct re *head)\r\n{\r\n\t\r\n\tstruct re *p;\r\n\tp=head;\r\n\tif(head!=NULL)\r\n\t{\r\n\t\tdo\r\n\t\t{\r\n\t\t\tprintf(\"%d\",p->ch);\r\n\t\t\tp=p->next;\r\n\t\t\t\r\n\t\t}while(p!=NULL);\r\n\t\t\r\n\t}\r\n}\r\nint main()\r\n{\r\n\tint n;\r\n\tprintf(\"请输入要逆向的数字个数：\\t\");\r\n\tscanf(\"%d\",&n);\r\n\tstruct re*head;\r\n\thead=creat(n);\r\n\thead=reverse(head);\r\n\tprint(head);\r\n\treturn 0;\r\n}\r\n```\r\n\r\n# 宿舍管理系统\r\n```c\r\n#include<stdio.h>\r\n#include<stdlib.h>\r\n#include<string.h>\r\ntypedef struct room{\r\n\tint id;\r\n\tchar name[100];\r\n\tchar sex[100];\r\n\tint age;\r\n\tint x;   //宿舍号 \r\n\tint y;   //床位号 \r\n\tstruct room*next;\r\n}room;\r\nroom* creat(int n)\r\n{\r\n\tint k=0;\r\n\troom*p,*head;\r\n\thead=NULL;\r\n\twhile(k<n)\r\n\t{\r\n\t\tp=(room*)malloc(sizeof(room));\r\n\t\tprintf(\"\\n请输入学生学号\\n\");\r\n\t    scanf(\"%d\",&p->id);\r\n\t    printf(\"\\n请输入学生姓名\\n\");\r\n\t    scanf(\"%s\",p->name);\r\n\t    printf(\"\\n请输入学生性别\\n\");\r\n\t    scanf(\"%s\",p->sex);\r\n\t    printf(\"\\n请输入学生年龄\\n\");\r\n\t    scanf(\"%d\",&p->age);\r\n\t    printf(\"\\n请输入学生的宿舍号\\n\");\r\n\t\tscanf(\"%d\",&p->x);\r\n\t\tprintf(\"\\n请输入学生的床位号\\n\");\r\n\t\tscanf(\"%d\",&p->y);\r\n\t\tp->next=head;\r\n\t\thead=p;\r\n\t\tk++; \r\n\t}\r\n\treturn head;\r\n}\r\n//输出\r\nvoid pt(room*head)\r\n{\r\n\troom*p;\r\n\tp=head;\r\n\tif(p==NULL)\r\n\t{\r\n\t\tprintf(\"空\");\r\n\t}\r\n\telse \r\n\twhile(p!=NULL)\r\n\t{\r\n\t\tprintf(\"\\n学号：%d\\t姓名：%s\\t性别：%s年龄：%d\\t宿舍:%d\\t床位:%d\\n\",p->id,p->name,p->sex,p->age,p->x,p->y);\r\n\t\tp=p->next;\r\n\t}\r\n } \r\n //查询\r\n room* scearch(room*head)\r\n {\r\n \troom *p;\r\n\tp=head;\r\n  \tchar namee[100];\r\n  \tprintf(\"\\n请输入要查找的名字：\\n\");\r\n\tscanf(\"%s\",namee);\r\n\twhile(p)\r\n\t{\r\n\t\tif(strcmp(p->name,namee)==0)\r\n\t\t{\r\n\t\t\tprintf(\"\\n学号：%d\\t姓名：%s\\t性别：%s年龄：%d\\t宿舍:%d\\t床位:%d\\n\",p->id,p->name,p->sex,p->age,p->x,p->y);\t\t\t\r\n\t\t}\r\n\t\tif(strcmp(p->name,namee)!=0&&p->next==NULL)\r\n\t\t{\r\n\t\t\tprintf(\"\\n未找到该同学\\n\"); \r\n\t\t}\r\n\t\tp=p->next;\r\n\t}\r\n  \treturn p;\r\n  } \r\n  //插入\r\nroom* find(room* head)\r\n{\r\n\troom*p,*q,*q1;\r\n\tp=head;\r\n\tchar name2[100];\r\n\tprintf(\"\\n请输入要插入的位置的前一位姓名：\\n\");\r\n\tscanf(\"%s\",name2);\r\n\twhile(p&&strcmp(p->name,name2)!=0)\r\n\t{\r\n\t\tp=p->next;\r\n\t}\r\n\t char name1[100],sex1[100];\r\n\t int id1,age1,x1,y1;\r\n\t printf(\"\\n请输入添加同学的学号，姓名，性别，年龄\\n\");\r\n\t scanf(\"%d%s%s%d%d%d\",&id1, name1, sex1, &age1, &x1, &y1);\t\r\n\t q=head;\r\n\t q1=p;\r\n\t q=(room*)malloc(sizeof(room));\r\n\t q->id=id1;\r\n\t strcpy(q->name,name1);\r\n\t strcpy(q->sex,sex1);\r\n\t q->age=age1;\r\n\t q->x=x1;\r\n\t q->y=y1;\r\n\t if(q1==head)\r\n\t {\r\n\t \tq->next=head;\r\n\t \thead=q;\r\n\t }\r\n\t else\r\n\t {\r\n\t \tq->next=q1->next;\r\n\t \tq1->next=q;\r\n\t }\r\n\treturn head;\r\n}\r\nroom* dete(room *head)\r\n{\r\n\troom *p,*pp;\r\n\tif(head==NULL)\r\n\t{\r\n\t\tprintf(\"链表为空!\");\r\n\t}\r\n\tchar namee[100];\r\n\tprintf(\"\\n请输入要删除的名字:\\n\");\r\n\tscanf(\"%s\",namee);\r\n\tp=head;\r\n\tpp=NULL; \r\n\twhile(p&&strcmp(p->name,namee)!=0)\r\n\t{\r\n\t\tpp=p;\r\n\t\tp=p->next;\r\n\t}\r\n\tif(p==NULL)\r\n\t{\r\n\t\tprintf(\"\\n没有找到要删除的同学\\n\");\r\n\t}\r\n\tif(!pp&&strcmp(p->name,namee)==0)\r\n\thead=NULL;\r\n\telse \r\n\tpp->next=p->next;\r\n\tdo{\r\n\t\tp=p->next;\r\n\t}while(p!=NULL);\r\n\treturn head;\r\n}\r\nvoid enter(room *head,int n)\r\n{\r\n\tFILE *fp;\r\n\tfwrite(head,sizeof(room),n,fp);\r\n\tprintf(\"成功录入!\");\r\n}\r\nint main()\r\n{\r\n\troom* list;\r\n\tint n,a;\r\n\tprintf(\"\\n请输入所创建的容量\\n\");\r\n\tscanf(\"%d\",&n); \r\n\tprintf(\"\\n请输入各同学信息：\\n\");\r\n\tlist=creat(n); \r\n\tint input;\r\n\twhile(1)\r\n\t{\r\n\t\tprintf(\"\\n请输入要执行操作序号：\\n1、输出\\n2、查找某同学的信息\\n3、删除某同学信息\\n4、插入\\n\");\r\n\t    scanf(\"%d\",&input);\r\n\t    switch(input)\r\n\t{\r\n\tcase 1:pt(list);break;\r\n\tcase 2:scearch(list);break;\r\n\tcase 3:list = dete(list);break;\r\n\tcase 4:list = find(list);break;\r\n\t}\r\n\t\tprintf(\"完成时请输入 0 ,继续操作请输入 1 \\n\"); \r\n\t\tscanf(\"%d\",&a);\r\n\t\tif(a==0) break;\r\n\t\t\r\n\t}\r\n\tenter (list,n);\r\n\t return 0;\r\n} \r\n```"},"comment":{"url":"https://api.github.com/repos/android-nuc/18-C-Train/issues/comments/445420871","html_url":"https://github.com/android-nuc/18-C-Train/issues/28#issuecomment-445420871","issue_url":"https://api.github.com/repos/android-nuc/18-C-Train/issues/28","id":445420871,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NTQyMDg3MQ==","user":{"login":"yanlianga","id":44320787,"node_id":"MDQ6VXNlcjQ0MzIwNzg3","avatar_url":"https://avatars3.githubusercontent.com/u/44320787?v=4","gravatar_id":"","url":"https://api.github.com/users/yanlianga","html_url":"https://github.com/yanlianga","followers_url":"https://api.github.com/users/yanlianga/followers","following_url":"https://api.github.com/users/yanlianga/following{/other_user}","gists_url":"https://api.github.com/users/yanlianga/gists{/gist_id}","starred_url":"https://api.github.com/users/yanlianga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yanlianga/subscriptions","organizations_url":"https://api.github.com/users/yanlianga/orgs","repos_url":"https://api.github.com/users/yanlianga/repos","events_url":"https://api.github.com/users/yanlianga/events{/privacy}","received_events_url":"https://api.github.com/users/yanlianga/received_events","type":"User","site_admin":false},"created_at":"2018-12-08T02:02:12Z","updated_at":"2018-12-08T02:02:12Z","author_association":"NONE","body":"> 修改：\r\n> \r\n> * 链表倒序\r\n>   * 已添加提示信息\r\n> * 宿舍管理系统\r\n>   \r\n>   *删除操作已修改\r\n>   * 文件已添加（可能还存在错误，希望学长指正）\r\n\r\n"}}
{"actor":{"display_login":"yanlianga"}}