第十二周作業

2022-06-29 06:12:17 字數 2566 閱讀 4873

1,計算最長的字串長度

本題要求實現乙個函式,用於計算有n個元素的指標陣列s中最長的字串的長度。

int max_len( char *s, int n );

其中n個字串儲存在s中,函式max_len應返回其中最長字串的長度。

#include #include #include #define maxn 10

#define maxs 20

int max_len( char *s, int n );

int main()

; scanf("%d", &n);

for(i = 0; i < n; i++)

printf("%d\n", max_len(string, n));

return 0;

}

4

blue

yellow

redgreen

6
實驗**

int max_len( char *s, int n )

;

這裡學生的學號共7位數字,其中第2、3位是專業編號。計算機專業的編號為02。

int countcs( struct listnode *head );
其中head是使用者傳入的學生學號鍊錶的頭指標;函式countcs統計並返回head鍊錶中專業為計算機的學生人數。

#include #include #include struct listnode ;

struct listnode *createlist(); /*裁判實現,細節不表*/

int countcs( struct listnode *head );

int main()

1021202

2022310

8102134

1030912

3110203

4021205

#

3
實驗**

int countcs( struct listnode *head )

return num;

}

實驗思路

遇到的問題

沒什麼特別大的問題

3, 刪除單鏈表偶數節點

本題要求實現兩個函式,分別將讀入的資料儲存為單鏈表、將鍊錶中偶數值的結點刪除。鍊錶結點定義如下:

struct listnode ;
struct listnode *createlist();

struct listnode *deleteeven( struct listnode *head );

函式createlist從標準輸入讀入一系列正整數,按照讀入順序建立單鏈表。當讀到−1時表示輸入結束,函式應返回指向單鏈表頭結點的指標。

函式deleteeven將單鏈表head中偶數值的結點刪除,返回結果鍊錶的頭指標。

#include #include struct listnode ;

struct listnode *createlist();

struct listnode *deleteeven( struct listnode *head );

void printlist( struct listnode *head )

printf("\n");

}int main()

1 2 2 3 4 5 6 7 -1
1 3 5 7
實驗**

遇到的問題

這個題目不是很會上網查了一下**好長好長而且有蠻多看不懂

預習作業

從第十三周開始,將進入課程設計階段,請在本次作業中給出:

1.所在小組想要開發的專案的名稱和目標;

說實話現在還很麻木迷茫

2.專案主體功能的描述;

不知道3.現階段已做的準備工作;

在進行討論了

4.小組成員名單和進度安排。

劉俊 唐嘉誠 李雨帆

學習感悟

指標的高階還不是很懂,有些東西分不清

結對程式設計感悟

沒什麼說的了隊友和我都是小白只能靠自己和他人

學習進度表

第十二周作業

例題1 includeusing namespace std struct date struct student int main stu1,stu2 stu1.num 1001 stu1.age 20 stu2 stu1 cout includeusing namespace std struc...

第十二周作業

1 多文件窗體 mdi form 功能演示 2 日期控制項datetimepicker功能演示 3 月曆控制項monthcalender功能演示 4 樹型列表控制項treeview功能演示 tn.expand 展開tn節點 treeview1.selectednode tn1 把新增節點設定為當前選...

第十二周作業

一.jpanel 方法型別 描述public jpanel 構造建立乙個預設的jpanel物件,使用流布局管理器 public jpanel layoutmanager layout 構造建立乙個指定布局管理器的jpanel物件 二.jsplitpane 三.jtabbedpane 四.jscrol...