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

為了賬號安全,請及時綁定郵箱和手機立即綁定

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

探索學習新天地,共享知識資源!

0 提交作業(yè)
0 布置作業(yè)
0 滿分作業(yè)
得分 100
討論題

RX0_UNICORN 的學生作業(yè):

// joseph.h #ifndef __JOSEPH_H__ #define __JOSEPH_H__ #include #include typedef int datatype_t; typedef struct node { datatype_t data; struct node *next; }loopnode_t; extern loopnode_t *create_circular_linklist(int n); extern void josephus_problem(int n, int k, int m); #endif // joseph.c #include "joseph.h" // 創(chuàng)建循環(huán)鏈表 loopnode_t *create_circular_linklist(int n) { if (n data = 1; loopnode_t *current = head; for (int i = 2; i data = i; current->next = newNode; current = newNode; } // 將鏈表首尾相連形成循環(huán) current->next = head; return head; } // 解決約瑟夫問題 void josephus_problem(int n, int k, int m) { // 創(chuàng)建循環(huán)鏈表 loopnode_t *head = createCircularLinkedList(n); if (head == NULL) return; // 移動到第k個節(jié)點 loopnode_t *current = head; loopnode_t *prev = NULL; // 找到第k個節(jié)點 for (int i = 1; i < k; i++) { prev = current; current = current->next; } while (current->next != current) { // 數(shù)m-1次,因為當前節(jié)點從1開始計數(shù) for (int i = 1; i < m; i++) { prev = current; current = current->next; } // 刪除當前節(jié)點 prev->next = current->next; printf("%d ", current->data); // 如果不是最后一個節(jié)點,打印逗號分隔 if (current->next != prev->next) { printf(" "); } loopnode_t *temp = current; current = current->next; free(temp); } // 處理最后一個節(jié)點 printf("%d\n", current->data); free(current); } // main.c #include "joseph.h" int main(int argc, const char *argv[]) { int n, k, m; printf("please input n k m : "); scanf("%d%d%d", &n, &k, &m); printf("n = %d, k = %d, m = %d 時的出列序列:\n", n, k, m); josephus_problem(n, k, m); return 0; } 【圖片】

得分 100
討論題

RX0_UNICORN 的學生作業(yè):

// linklist.h #ifndef __LINKLIST_H__ #define __LINKLIST_H__ #include #include #include typedef int datatype_t; typedef struct node { datatype_t data; // 數(shù)據(jù)域 保存有效的數(shù)據(jù) struct node *next; // 指針域 保存下一個結點地址 }linklist_t; extern linklist_t *create_empty_linklist(); extern void insert_head_linklist(linklist_t *head, datatype_t data); extern void insert_tail_linklist(linklist_t *head, datatype_t data); extern void insert_order_linklist(linklist_t *head, datatype_t data); extern void print_data_linklist(linklist_t *head); #endif // linlist.c #include "linklist.h" // 創(chuàng)建一個新的鏈表---為頭結點分配堆區(qū)空間 linklist_t *create_empty_linklist() { // 為頭結點分配堆區(qū)空間 linklist_t *head = NULL; head = (linklist_t *)malloc(sizeof(linklist_t)); if(NULL == head) { printf("malloc is fail!\n"); return NULL; } memset(head, 0, sizeof(linklist_t)); head->next = NULL; // 該步驟可省略 return head; } // 頭插法,每次都在頭結點后插入數(shù)據(jù) // [特點:插入順序和輸出順序是相反的] void insert_head_linklist(linklist_t *head, datatype_t data) { // 分配空間 linklist_t *temp = NULL; temp = (linklist_t *)malloc(sizeof(linklist_t)); // 將 data 存入 temp 的數(shù)據(jù)域 temp->data = data; // 將 temp 插入 head 后面 temp->next = head->next; head->next = temp; return; } // 尾插法 void insert_tail_linklist(linklist_t *head, datatype_t data) { // 分配空間 linklist_t *temp = NULL; temp = (linklist_t *)malloc(sizeof(linklist_t)); // 將 data 存入 temp 的數(shù)據(jù)域 temp->data = data; linklist_t *p = head; // 遍歷循環(huán)找到尾結點 while(p->next != NULL) { p = p->next; } // 將 temp 插入 p 后面 temp->next = p->next; p->next = temp; return; } // 有序法 void insert_order_linklist(linklist_t *head, datatype_t data) { linklist_t *temp = NULL; temp = (linklist_t *)malloc(sizeof(linklist_t)); temp->data = data; linklist_t *p = head; while(p->next != NULL && data < p->next->data) { p = p->next; } temp->next = p->next; p->next = temp; return; } // 輸出鏈表中的數(shù)據(jù) void print_data_linklist(linklist_t *head) { linklist_t *p = head; while(p->next != NULL) // next 為 NULL 時停止打印 { printf("%d ", p->next->data); p = p->next; } printf("\n"); return; } // main.c #include "linklist.h" int main(int argc, const char *argv[]) { datatype_t data = 0; int data_num = 0, i = 0; linklist_t *head = create_empty_linklist(); printf("please input you want save data num : "); scanf("%d", &data_num); printf("please input %d data : ", data_num); for(i = 0; i < data_num; i++) { scanf("%d", &data); // insert_head_linklist(head, data); // insert_tail_linklist(head, data); insert_order_linklist(head, data); } print_data_linklist(head); return 0; } 【圖片】

得分 100
討論題

cjozGV 的學生作業(yè):

#include "stdlib.h" #include "stdio.h" #include "string.h" #include "stdbool.h" typedef int datatype_t; #define MAX_SIZE 13 //棧的最大容量 typedef struct{ char *data; //動態(tài)分配的數(shù)組指針 int top; // 棧頂指針; }SequentialStack; //初始化棧(動態(tài)分配內(nèi)存) void initStack(SequentialStack *stack){ stack->data = (char *)malloc(MAX_SIZE * sizeof(char)); if (!stack->data){ //檢查分配是否成功 printf("malloc is fail!\n"); } stack->top = -1; //初始化棧頂指針 } //釋放棧內(nèi)存 void freeStack(SequentialStack *stack){ free(stack->data); //釋放動態(tài)內(nèi)存 stack->data = NULL; //避免空指針 stack->top = -1; //重置棧頂指針 } bool push(SequentialStack *stack,char value){ if (stack->top >= MAX_SIZE -1){ printf("棧已滿\n"); return false; } stack->data[++stack->top] = value; // 棧頂指針 +1,然后存值 return true; } void display(SequentialStack *stack){ if (stack->top == -1){ printf("棧已空"); return; } printf("棧內(nèi)容(從棧底到棧頂)"); for (int i = 0; i top;i++) { printf("%c ",stack->data[i]); } printf("\n"); } int main(){ SequentialStack stack; initStack(&stack); char data[] = {'a', 'n', 'i', 'h', 'c', ' ', 'e', 'v', 'o', 'l', ' ', 'I'}; for (int i = 0; i < sizeof(data) / sizeof(data[0]);i++) { push(&stack,data[i]); } display(&stack); freeStack(&stack); return 0; }

得分 100
學習任務

RX0_UNICORN 的學生作業(yè):

// seqlist.h #ifndef __SEQLIST_H__ #define __SEQLIST_H__ #include #include #include #define MAX 10 struct student { char name[20]; int id; int age; }; typedef struct student datatype_t; typedef struct { datatype_t buf[MAX]; int n; }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 print_data_seqlist(seqlist_t *l); #endif // seqlist.c #include "seqlist.h" seqlist_t *create_empty_seqlist() { seqlist_t *l = (seqlist_t *)malloc(sizeof(seqlist_t)); if(NULL == l) { printf("malloc is fail!"); return NULL; } memset(l, 0, sizeof(seqlist_t)); l -> n = 0; return l; } int is_full_seqlist(seqlist_t *l) { return l->n < MAX ? 1 : 0; } void insert_data_seqlist(seqlist_t *l, datatype_t data) { l->buf[l->n] = data; l->n++; } void print_data_seqlist(seqlist_t *l) { printf("NAME\tID\tAGE\n"); printf("---------------------------------\n"); for(int i = 0; i < l->n; i++) { printf("%s\t%d\t%d\n", l->buf[i].name, l->buf[i].id, l->buf[i].age); printf("---------------------------------\n"); } } // main.c #include "seqlist.h" int main(int argc, const char *argv[]) { seqlist_t *l = create_empty_seqlist(); while(is_full_seqlist(l)) { printf("Please input no more than %d student info[NAME ID AGE] : ", MAX - l->n); datatype_t std; scanf("%s%d%d", std.name, &(std.id), &(std.age)); insert_data_seqlist(l, std); } print_data_seqlist(l); free(l); l = NULL; return 0; } 【圖片】

微信客服

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

幫助反饋 APP下載

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

公眾號

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