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

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

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

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

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

工地少年與磚('?') 的學(xué)生作業(yè):

最終效果【圖片】 stu_seq.h #ifndef __INT_SEQ_H__ #define __INT_SEQ_H__ #include #define MAX_COUNT 3 // 實(shí)際學(xué)?的存儲(chǔ) typedef struct student { char name[20]; int id; int age; } student; typedef student datatype_t; // 存儲(chǔ)學(xué)生對(duì)象的數(shù)組結(jié)構(gòu) typedef struct seqlist_t { datatype_t* buf[MAX_COUNT]; unsigned int n; } seqlist_t; // 初始化對(duì)象 extern seqlist_t* create_empty_seqlist(); // 序列是否已滿 bool is_full_seqlist(seqlist_t* l); // 向序列中插入數(shù)據(jù) extern void insert_data_seqlist(seqlist_t* l, datatype_t data); // 打印序列中的數(shù)據(jù) extern void printf_data_seqlist(const seqlist_t* l); // 判斷容器數(shù)據(jù)是否為空 extern bool is_empty(const seqlist_t* l); // 刪除數(shù)據(jù) extern void delete_data_seqlist(seqlist_t* l, int id); #endif stu_seq.c #include #include #include #include "stu_seq.h" seqlist_t* create_empty_seqlist() { // c語(yǔ)言中, 可以不用對(duì)void*進(jìn)行強(qiáng)轉(zhuǎn) seqlist_t* seq = malloc(sizeof(seqlist_t)); if (NULL == seq) { printf("malloc failure \n"); return seq; } memset(seq, 0, sizeof(seqlist_t)); seq->n = 0; return seq; } bool is_full_seqlist(seqlist_t* l) { if (MAX_COUNT == l->n) return true; return false; } void insert_data_seqlist(seqlist_t* l, datatype_t data) { bool res = is_full_seqlist(l); if (res) { printf("容量已滿"); return; } datatype_t* tmp = malloc(sizeof(datatype_t)); tmp->id = data.id; strcpy(tmp->name, data.name); tmp->age = data.age; // data是一個(gè)值, 不是一個(gè)指針, 所以會(huì)拷貝它的數(shù)據(jù)在我們的堆中 l->buf[l->n] = tmp; (l->n)++; } void printf_data_seqlist(const seqlist_t* l) { unsigned int i = 0; for (i = 0; i n; i++) { printf("id = %d, name = %s, age = %d \n", l->buf[i]->id, l->buf[i]->name, l->buf[i]->age); } } bool is_empty(const seqlist_t* l) { if (l->n == 0) { return true; } return false; } bool findTargetIndex(seqlist_t* l, unsigned int* targetIndex, int id) { unsigned int i = 0; for (i = 0; i n; i++) { if (id == l->buf[i]->id) { *targetIndex = i; return true; } } return false; } void delete_data_seqlist(seqlist_t* l, int id) { // sequence delete , after element cover prev element unsigned int targetIndex = 0; // find target index const bool findRes = findTargetIndex(l, &targetIndex, id); if (!findRes) { printf("id不存在, 請(qǐng)檢查后重試 \n"); return; } unsigned int index = l->n - 1; seqlist_t* lateFreeData = l->buf[targetIndex]; for (index = l->n - 1; index > targetIndex; index--) { l->buf[index - 1] = l->buf[index]; } l->n--; free(lateFreeData); } main.c #include #include "stu_seq.h" int main(int argc, char const* argv[]) { // 初始化列表 seqlist_t* l = create_empty_seqlist(); unsigned int c = 0; datatype_t stu; for (c = 0; c

微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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