第十二周程式設計總結

2022-02-27 07:43:27 字數 3077 閱讀 4587

這個作業屬於那個課程

c語言程式設計2

這個作業要求在**

2023年春季學期第十二周作業

我在這個課程的目標是

學會鍊錶的初步使用

這個作業在那個具體方面幫助我實現目標

理解鍊錶

參考文獻

書上鍊表章節

本題要求實現乙個函式,用於計算有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;

}

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 b;

}

以煉表頭不為空為前提,判斷第二位數字和第三位是不是02是則b++並讀入下一節點。

4*head).code[1]對於這種表示方式不是很熟練。

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

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

struct listnode *createlist()

return head;

} struct listnode *deleteeven( struct listnode *head )

if(head==null)

return null;

str1=head;

str2=head-> next;

while(str2!=null)

else

str1=str2;

str2=str1->next;

}return head;

}

根據書上的鍊錶寫的;思路還有點模糊得再看看。

理論課結束了;在這個學期任務比上個學期重很多但學的也比上個學期多很多;感覺現在比以前懂的多很多了;但不足之處也有很多c語言所學章節中所遇問題還有很多理解的很模糊;然後接下來雖然主要要放在課程設計上;但也得複習以前的pta題目了。

預習題:

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

名稱:衝塔

目標:小遊戲,一層一層的闖關。

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

在電腦上控制人物的移動,解鎖門來吃經驗,獲得增益性攻擊和防禦。

3.現階段已做的準備工作:

沒有確定的創意了,有目標了,有人員了,學習基礎知識逐漸提公升。

4.小組成員名單和進度安排。(課程設計階段:13-17周)

黃諾誠(組長)謝思敏 夏澤宇

第十二周程式設計總結

7 1 程式設計列印空心字元菱形 10 分 本題目要求讀入菱形起始字母和菱形的高度,然後輸出空心字元菱形。所謂 空心菱形 是指 每行由兩端為字母 中間為空格的字串構成,每行的字串中心對齊 上半部分相鄰兩行字串長度差2,且字母從給定的起始字母逐一遞增 下半部分與上半部分對稱。1 實驗 include ...

第十二周程式設計總結

美國 歐巴馬不僅呼籲所有人都學習程式設計,甚至以身作則編寫 成為美國歷史上首位編寫計算機 的 2014年底,為慶祝 電腦科學教育周 正式啟動,歐巴馬編寫了很簡單的計算機 在螢幕上畫乙個正方形。現在你也跟他一起畫吧!1 實驗 include int main printf n return 0 2 設...

第十二周程式設計總結

6 1 計算最長的字串長度 15 分 本題要求實現乙個函式,用於計算有n個元素的指標陣列s中最長的字串的長度。函式介面定義 int max len char s,int n 其中n個字串儲存在s中,函式max len應返回其中最長字串的長度。裁判測試程式樣例 int max len char s,i...