最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

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

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

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

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

慕尼黑0001808 的學(xué)生作業(yè):

//寫出下列類型的判空,刪除 #ifndef __LIST_H__ #define __LIST_H__ #include #include #include #define MAX 10 //實(shí)際學(xué)生的存儲(chǔ) struct student { char name[20]; int id; int age; }; typedef struct student datatype_t; typedef struct{ datatype_t buf[MAX]; //定義數(shù)組記錄班級(jí)學(xué)?每個(gè)學(xué)?的信息。 int n; //學(xué)?實(shí)際到來的個(gè)數(shù)。 }seqlist_t; extern seqlist_t *create_empty_seqlist(); extern void printf_data_seqlist(seqlist_t * l); extern int is_empty_seqlist(seqlist_t *l); extern int delete_data_seqlist(seqlist_t *l,datatype_t data); #endif // list.c #include "list.h" //創(chuàng)建空的順序表 seqlist_t *create_empty_seqlist() { seqlist_t * l = (seqlist_t *)malloc(sizeof(seqlist_t)); if (NULL == l) { printf("malloc seqlist_t fail \n"); return NULL; } return l; } // 打印數(shù)據(jù) void printf_data_seqlist(seqlist_t * l) { printf("id\tname\tage\n"); for(int i = 0;in;i++) { printf("%d\t%s\t%d\n",l->buf[i].id,l->buf[i].name,l->buf[i].age); } printf("\n"); } //判斷順序表是否為空 int is_empty_seqlist(seqlist_t *l) { return l->n==0?1:0; } //刪除順序表中指定的數(shù)據(jù) int delete_data_seqlist(seqlist_t *l,datatype_t data) { int i = 0,j = 0; if(is_empty_seqlist(l)) { return -1; } for(;in;i++) { // 如果當(dāng)前元素與要?jiǎng)h除的元素不匹配,則保留它 if(!(strcmp(l->buf[i].name,data.name)==0&&l->buf[i].id==data.id&&l->buf[i].age==data.age)) { l->buf[j++] = l->buf[i]; } // 如果匹配(是要?jiǎng)h除的元素),則跳過它,不增加j } // 檢查是否刪除了元素 if(i==j) { // 沒有找到要?jiǎng)h除的元素 return -2; } l->n = j; return 0; } // main.c #include "list.h" int main() { seqlist_t * l = create_empty_seqlist(); datatype_t data[10] = { {"Alice", 1001, 18}, {"Bob", 1002, 19}, {"Charlie", 1003, 20}, {"David", 1004, 21}, {"Eve", 1005, 19}, {"Frank", 1006, 22}, {"Grace", 1007, 20}, {"Helen", 1008, 23}, {"Ivy", 1009, 21}, {"Jack", 1010, 20} }; memcpy(l->buf,data,sizeof(data)); l->n = 10; printf("刪除前:\n"); printf_data_seqlist(l); int result = delete_data_seqlist(l,data[1]); // 刪除 Bob printf("刪除結(jié)果: %d\n", result); printf("刪除后:\n"); printf_data_seqlist(l); free(l); l = NULL; return 0; }

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

慕尼黑0001808 的學(xué)生作業(yè):

#ifndef __LIST_H__ #define __LIST_H__ // list.h //寫出下列類型的創(chuàng)建,判滿,插入輸出 #include #include #include #define MAX 10 //實(shí)際學(xué)?的存儲(chǔ) struct student { char name[20]; int id; int age; }; typedef struct student datatype_t; typedef struct{ datatype_t buf[MAX]; //定義數(shù)組記錄班級(jí)學(xué)?每個(gè)學(xué)?的信息。 int n; //學(xué)?實(shí)際到來的個(gè)數(shù)。 }seqlist_t; seqlist_t *create_empty_seqlist(); int is_full_seqlist(seqlist_t *l); void insert_data_seqlist(seqlist_t *l,datatype_t data); void printf_data_seqlist(seqlist_t *l); #endif // list.c #include "list.h" //創(chuàng)建空的順序表 seqlist_t *create_empty_seqlist() { seqlist_t * l = (seqlist_t *)malloc(sizeof(seqlist_t)); if (NULL == l) { printf("malloc seqlist_t fail \n"); return NULL; } return l; } // 判斷順序表是否已滿 int is_full_seqlist(seqlist_t * l) { return l->n == MAX ? 1 : 0; } // 插入數(shù)據(jù) void insert_data_seqlist(seqlist_t *l,datatype_t data) { l->buf[l->n] = data; l->n++; } void printf_data_seqlist(seqlist_t * l) { printf("id\tname\tage\n"); for(int i = 0;ibuf[i].id,l->buf[i].name,l->buf[i].age); } printf("\n"); } // main.c #include "list.h" int main() { seqlist_t * l = create_empty_seqlist(); datatype_t data; while(is_full_seqlist(l)==0) { printf("please %d data[name id age]:",MAX); scanf("%s%d%d",data.name,&data.id,&data.age); insert_data_seqlist(l,data); } printf_data_seqlist(l); free(l); l = NULL; return 0; }

微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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