第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

作業(yè)社區(qū)

探索學(xué)習(xí)新天地,共享知識資源!

0 提交作業(yè)
0個(gè) 布置作業(yè)
0 滿分作業(yè)
得分 100
學(xué)習(xí)任務(wù)

慕運(yùn)維8597106 的學(xué)生作業(yè):

seqlist.h #ifndef __SEQLIST_H__ #define __SEQLIST_H__ #define MAX 10 struct student { char name[20]; int id; int age; }; typedef struct student data_type_t; typedef struct { data_type_t buf[MAX]; int n; } seqlist_t; extern seqlist_t *create_empty_seqlist(); extern int is_full_seqlist(seqlist_t *l); extern void insert_data_seqlist(seqlist_t *l,data_type_t data); extern void print_data_seqlist(seqlist_t *l); int is_empty_seqlist(seqlist_t *l); int delete_data_seqlist(seqlist_t *l,data_type_t data); #endif seqlist.c #include #include "seqlist.h" #include #include seqlist_t *create_empty_seqlist() { seqlist_t *p = (seqlist_t *) malloc(sizeof(seqlist_t)); if(NULL == p) { printf("malloc failed!\n"); return NULL; } memset(p,0,sizeof(seqlist_t)); p->n = 0; return p; } int is_full_seqlist(seqlist_t *l) { if(l->n >= MAX) { return 1; } return 0; } void insert_data_seqlist(seqlist_t *l,data_type_t data) { if(is_full_seqlist(l)) { printf("seqlist is full!\n"); return; } l->buf[l->n] = data; l->n++; } void print_data_seqlist(seqlist_t *l) { if(NULL != l) { for(int i = 0;i < l->n;i++) { printf("%s\t%d\t%d ",l->buf[i].name,l->buf[i].id,l->buf[i].age); printf("\n"); } } } int is_empty_seqlist(seqlist_t *l) { if(NULL == l || l->n == 0) { return 1; } return 0; } int delete_data_seqlist(seqlist_t *l,data_type_t data) { if(is_empty_seqlist(l)) { return 0; } int i = 0,j = 0; for(i = 0;i < l->n;i++) { if(l->buf[i].age != data.age){ l->buf[j] = l->buf[i]; j++; } } l->n = j; } main.c #include #include "seqlist.h" #include #include int main(int argc, const char *argv[]) { seqlist_t *p = create_empty_seqlist(); if(NULL != p) { data_type_t stu = {"zs",1,25}; insert_data_seqlist(p,stu); strcpy(stu.name,"lisi"); stu.id = 2; stu.age = 27; insert_data_seqlist(p,stu); strcpy(stu.name,"wangwu"); stu.id = 3; stu.age = 35; insert_data_seqlist(p,stu); strcpy(stu.name,"zhaoliu"); stu.id = 6; stu.age = 22; insert_data_seqlist(p,stu); strcpy(stu.name,"zhouqi"); stu.id = 7; stu.age = 24; insert_data_seqlist(p,stu); strcpy(stu.name,"liuba"); stu.id = 8; stu.age = 17; insert_data_seqlist(p,stu); strcpy(stu.name,"niu9"); stu.id = 9; stu.age = 35; insert_data_seqlist(p,stu); print_data_seqlist(p); data_type_t target; printf("請輸入刪除掉人員的目標(biāo)年齡:"); scanf("%d",&target.age); delete_data_seqlist(p,target); printf("===刪除年齡%d歲后===\n",target.age); print_data_seqlist(p); free(p); p = NULL; } return 0; } 執(zhí)行結(jié)果 linux@linux:~/learn/chapter5/seqlist$ ./a.out zs 1 25 lisi 2 27 wangwu 3 35 zhaoliu 6 22 zhouqi 7 24 liuba 8 17 niu9 9 35 請輸入刪除掉人員的目標(biāo)年齡:35 ===刪除年齡35歲后=== zs 1 25 lisi 2 27 zhaoliu 6 22 zhouqi 7 24 liuba 8 17

得分 100
學(xué)習(xí)任務(wù)

慕運(yùn)維8597106 的學(xué)生作業(yè):

seqlist.h #ifndef __SEQLIST_H__ #define __SEQLIST_H__ #define MAX 10 struct student { char name[20]; int id; int age; }; typedef struct student data_type_t; typedef struct { data_type_t buf[MAX]; int n; } seqlist_t; extern seqlist_t *create_empty_seqlist(); extern int is_full_seqlist(seqlist_t *l); extern void insert_data_seqlist(seqlist_t *l,data_type_t data); extern void print_data_seqlist(seqlist_t *l); #endif seqlist.c #include #include "seqlist.h" #include #include seqlist_t *create_empty_seqlist() { seqlist_t *p = (seqlist_t *) malloc(sizeof(seqlist_t)); if(NULL == p) { printf("malloc failed!\n"); return NULL; } memset(p,0,sizeof(seqlist_t)); p->n = 0; return p; } int is_full_seqlist(seqlist_t *l) { if(l->n >= MAX) { return 1; } return 0; } void insert_data_seqlist(seqlist_t *l,data_type_t data) { if(is_full_seqlist(l)) { printf("seqlist is full!\n"); return; } l->buf[l->n] = data; l->n++; } void print_data_seqlist(seqlist_t *l) { if(NULL != l) { for(int i = 0;i < l->n;i++) { printf("%s\t%d\t%d ",l->buf[i].name,l->buf[i].id,l->buf[i].age); printf("\n"); } } } main.c #include #include "seqlist.h" #include int main(int argc, const char *argv[]) { seqlist_t *p = create_empty_seqlist(); if(NULL != p) { for(int i = 0;i < 11;i++) { data_type_t stu = {"zhangsan",i,100}; insert_data_seqlist(p,stu); } print_data_seqlist(p); free(p); p = NULL; } return 0; } 執(zhí)行結(jié)果 seqlist is full! zhangsan 0 100 zhangsan 1 100 zhangsan 2 100 zhangsan 3 100 zhangsan 4 100 zhangsan 5 100 zhangsan 6 100 zhangsan 7 100 zhangsan 8 100 zhangsan 9 100

微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號