国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

通過C語言娶百富美之鏈表與結構體結合!!!!!!

2019-11-06 06:21:04
字體:
來源:轉載
供稿:網友
 鏈表與結構體的結合,可以很好的方便輸入輸出,以后使用鏈表時只需要將結構體的信息稍作修改就可以使用,非常方便!!!下面是寫學生學號和姓名的結構體與鏈表的結合create函數!#include   <stdio.h>typedef struct node{  4     int number;  5     char name[20];  6 }node;  7  8 typedef struct student{  9     node information; 10     struct student *next; 11 }student; 12 13 int iCount; 14 15 struct student *create() 16 { 17     int i; 18     node information; 19     struct student *head;           //頭指針 方便以后插入與刪除等一系列操作 20     struct student *end;              //位置指針 21     struct student *new;             //創建空間的新指針 22     new = end = (struct student *)malloc(sizeof(student)); 23     head = NULL; 24     if(new == NULL)    //如果申請堆空間失敗 則結束進程返回-1 25     { 26         PRintf("申請空間失敗/n"); 27         goto err; 28     } 29     printf("請先輸入學號,再輸入姓名:/n"); 30     scanf("%d",&information.number); 31     scanf("%s",information.name); 32     new->information = information;    //把結構體信息直接輸入到鏈表中,方便快捷 33     for(i=0;new->information.number>0;i++) 34     { 35         iCount++; 36         if(iCount == 1) 37         { 38             new -> next = NULL; 39             end = new; 40             head = end; 41         } 42         else 43         { 44             new -> next = NULL; 45             end = new; 46             new = new -> next; 47         } 48         new = (struct student*)malloc(sizeof(student)); 49         scanf("%d",&information.number); 50         scanf("%s",information.name); 51         new -> information = information; 52     }53     return head; 54 err: 55     return -1; 56 } 57 58 int main() 59 { 60     student *A; 61     A = create(); 62     return 0; 63 }
上一篇:sdutacm-迷之好奇

下一篇:sdutacm-字典樹

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 象山县| 乌拉特后旗| 维西| 望奎县| 抚松县| 长葛市| 攀枝花市| 巩义市| 丹寨县| 沈丘县| 祥云县| 黄骅市| 永定县| 右玉县| 绥滨县| 桃园市| 广元市| 宜城市| 北安市| 昌邑市| 红安县| 精河县| 麻栗坡县| 玛沁县| 南陵县| 牟定县| 汾阳市| 汨罗市| 普格县| 绥化市| 睢宁县| 宁化县| 出国| 绥阳县| 蒙自县| 丹寨县| 拜城县| 西峡县| 醴陵市| 南丰县| 获嘉县|