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

為了賬號(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è):

有個(gè)字符串為char b[ ] = “ADDCDCCBCDDBDDD”用上述方法,對(duì)此字符串進(jìn)行編碼和解碼。 共有15個(gè)字符,占15byte; 統(tǒng)計(jì)每個(gè)字符占用的數(shù)量 A:1 B:2 C:4 D:8 把結(jié)點(diǎn)按照權(quán)值兩兩合并,小的放左邊,大的放右邊,形成huffman樹(shù) :15 :7 D:8 :3 C:4 A:1 B:2 對(duì)上圖數(shù)據(jù)進(jìn)行左0,右1的編碼活動(dòng)。 A:000 B:001 C:01 D:1 ADDCDCCBCDDBDDD對(duì)應(yīng)的編碼是 A DD C D C C B C D D B D D D 000 1 1 01 1 01 01 001 01 1 1 001 1 1 1 0001101101010010111001111 (25位/8 = 4bype) 對(duì)編碼0001101101010010111001111進(jìn)行解碼 第一次,0,0有子樹(shù),往下走,00,有子樹(shù),往下走,000,無(wú)子樹(shù),是葉子樹(shù),存儲(chǔ)著A。剩下編碼1101101010010111001111 第二次,1,無(wú)子樹(shù),是葉子樹(shù),存儲(chǔ)著D。剩下編碼101101010010111001111 第三次,1,無(wú)子樹(shù),是葉子樹(shù),存儲(chǔ)著D。剩下編碼01101010010111001111 第四次,0,0有子樹(shù),往下走,01,無(wú)子樹(shù),是葉子樹(shù),存儲(chǔ)著C。剩下編碼101010010111001111 第五次,1,無(wú)子樹(shù),是葉子樹(shù),存儲(chǔ)著D。剩下編碼01010010111001111 第六次,0,0有子樹(shù),往下走,01,無(wú)子樹(shù),是葉子樹(shù),存儲(chǔ)著C。剩下編碼010010111001111 第七次,0,0有子樹(shù),往下走,01,無(wú)子樹(shù),是葉子樹(shù),存儲(chǔ)著C。剩下編碼0010111001111 第八次,0,0有子樹(shù),往下走,00,有子樹(shù),往下走,001,無(wú)子樹(shù),是葉子樹(shù),存儲(chǔ)著B(niǎo)。剩下編碼0111001111 第九次,0,0有子樹(shù),往下走,01,無(wú)子樹(shù),是葉子樹(shù),存儲(chǔ)著C。剩下編碼11001111 第十次,1,無(wú)子樹(shù),是葉子樹(shù),存儲(chǔ)著D。剩下編碼1001111 第十一次,1,無(wú)子樹(shù),是葉子樹(shù),存儲(chǔ)著D。剩下編碼001111 第十二次,0,0有子樹(shù),往下走,00,有子樹(shù),往下走,001,無(wú)子樹(shù),是葉子樹(shù),存儲(chǔ)著B(niǎo)。剩下編碼111 第十三次,1,無(wú)子樹(shù),是葉子樹(shù),存儲(chǔ)著D。剩下編碼11 第十四次,1,無(wú)子樹(shù),是葉子樹(shù),存儲(chǔ)著D。剩下編碼1 第十五次,1,無(wú)子樹(shù),是葉子樹(shù),存儲(chǔ)著D。剩下編碼無(wú) 解碼后的數(shù)據(jù)位:ADDCDCCBCDDBDDD

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

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

// bittree.h #ifndef __BITTREE_H__ #define __BITTREE_H__ #define N 6 #include #include #include #include typedef char data_t; //樹(shù)節(jié)點(diǎn)結(jié)構(gòu)體 typedef struct bitree { int n;//保存編碼 data_t data;//保存字符 struct bitree * lchild;//保存左孩子 struct bitree * rchild;//保存右孩子 }bitree_t; // 隊(duì)列結(jié)構(gòu)體 typedef struct Queue{ bitree_t **data; int front; int real; int size; int capacity; }LinkQueue; // 二叉樹(shù)的遞歸創(chuàng)建 extern bitree_t * create_binatry_tree(int n); // 創(chuàng)建空隊(duì)列 extern LinkQueue * creat_empyt_linkqueue(); // 加入隊(duì)列 extern void enter_linkqueue(LinkQueue * q,bitree_t * value); // 彈出隊(duì)列 extern bitree_t * delte_linkqueu(LinkQueue * q); // 判斷隊(duì)列是否為空 extern bool is_emtpy_linkqueue(LinkQueue * q); #endif // bintree.c #include "bittree.h" bitree_t * create_binatry_tree(int n) { bitree_t * root = NULL; root = (bitree_t *)malloc(sizeof(bitree_t)); if(NULL == root) { printf("malloc root fail\n"); exit(EXIT_FAILURE); } memset(root,0,sizeof(bitree_t)); root->n = n; root->lchild = root->rchild = NULL; printf("input %d node data:",n); scanf("%c",&root->data); while(getchar()!='\n');//清除緩沖區(qū) if(2 * n lchild = create_binatry_tree(2 * n); } if(2 * n + 1 rchild = create_binatry_tree(2 * n + 1); } return root; } LinkQueue * creat_empyt_linkqueue() { LinkQueue * q = NULL; q = (LinkQueue *)malloc(sizeof(LinkQueue)); if(NULL == q) { printf("malloc Queue fail\n"); exit(EXIT_FAILURE); } q->capacity = N; q->front = q->real = q->size = 0; q->data = (bitree_t **)malloc(sizeof(bitree_t*)*N); if(NULL == q->data) { printf("malloc q->data fail\n"); exit(EXIT_FAILURE); } return q; } void enter_linkqueue(LinkQueue * q,bitree_t * value) { if(q->size capacity) { q->data[q->real] = value; q->real = (q->real + 1) % q->capacity; q->size++; } } bitree_t * delte_linkqueu(LinkQueue * q) { bitree_t * value; if(q->size > 0) { value = q->data[q->front]; q->front = (q->front + 1)%q->capacity; q->size--; } return value; } bool is_emtpy_linkqueue(LinkQueue * q) { return q->size == 0; } // main.c #include "bittree.h" int main() { bitree_t * root = NULL; bitree_t * temp = NULL; root = create_binatry_tree(1); LinkQueue *q = creat_empyt_linkqueue(); enter_linkqueue(q,root); while(!is_emtpy_linkqueue(q)) { temp = delte_linkqueu(q); printf("%c",temp->data); if(temp->lchild != NULL) { enter_linkqueue(q,temp->lchild); } if(temp->rchild != NULL) { enter_linkqueue(q,temp->rchild); } } printf("\n"); return 0; } 運(yùn)行結(jié)果 linux@linux-VMware-Virtual-Platform:~/study/homework/5-1-12/bintree$ gcc *.c linux@linux-VMware-Virtual-Platform:~/study/homework/5-1-12/bintree$ ./a.out input 1 node data:A input 2 node data:B input 4 node data:D input 5 node data:E input 3 node data:C input 6 node data:F ABCDEF linux@linux-VMware-Virtual-Platform:~/study/homework/5-1-12/bintree$

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

weixin_慕九州3042664 的學(xué)生作業(yè):

#include #include #include #include #include #include #include #include #define PATH “.” #define MAGIC 0xDEAD #define SEM_SIZE 2 int main(int argc, char *argv[]) { if(argc != 2) { fprintf(stderr, “Usage: [%s] \n”, argv[0]); exit(EXIT_FAILURE); } key_t key = ftok(PATH, MAGIC); if(key == -1) { perror(“ftok()”); exit(EXIT_FAILURE); } int semid = semget(key, SEM_SIZE, IPC_CREAT | 0644); if(semid == -1) { perror("semget()"); exit(EXIT_FAILURE); } // sem[0]: child can write // sem[1]: parent can write '\n'. unsigned short values[SEM_SIZE] = {0, 0}; int ret = semctl(semid, SEM_SIZE, SETALL, values); if(-1 == ret) { perror("semctl():"); exit(EXIT_FAILURE); } FILE *fp = fopen(argv[1], "a+"); if(NULL == fp) { perror("fopen():"); exit(EXIT_FAILURE); } int pid = fork(); if(pid == -1) { perror("fork():"); exit(EXIT_FAILURE); } else if(pid == 0) { struct sembuf wait_p = { .sem_num = 0, .sem_op = -1, .sem_flg = 0 }; struct sembuf signal_p = { .sem_num = 1, .sem_op = +1, .sem_flg = 0 }; for(int i = 0; i < 10; i++) { semop(semid, &wait_p, 1); time_t curtime; time(&curtime); struct tm *tm_now = localtime(&curtime); char buf[40] = ""; strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm_now); fwrite(buf, 1, strlen(buf), fp); fflush(fp); semop(semid, &signal_p, 1); } fclose(fp); exit(0); } else if(pid > 0) { struct sembuf wait_c = { .sem_num = 1, .sem_op = -1, .sem_flg = 0 }; struct sembuf signal_c = { .sem_num = 0, .sem_op = +1, .sem_flg = 0 }; for(int i = 1; i

微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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