這個作業屬於哪個課程
c語言程式設計2
這個作業的要求在**
我在這個課程的目標是
指標函式的應用,單向鍊錶的操作
這個作業在哪個具體方面幫助我實現目標
函式題中對指標的應用以及單向鍊錶(建立、增加、刪除、修改、遍歷)
參考文獻
c語言程式設計2
本題要求實現乙個函式,用於計算有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
1.實驗**int max_len( char *s, int n )
;
這裡學生的學號共7位數字,其中第2、3位是專業編號。計算機專業的編號為02。
函式介面定義:
其中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
1.實驗**int countcs( struct listnode *head )
return len;
}
2.設計思路
3.本題除錯過程碰到的問題及解決辦法
沒有錯誤
4.執行結果截圖
本題要求實現兩個函式,分別將讀入的資料儲存為單鏈表、將鍊錶中偶數值的結點刪除。鍊錶結點定義如下:
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()
head=head->next;
return(head);
}struct listnode*deleteeven(struct listnode*head)
p=head;
q=p->next;
while(q!=null)
else
}if(head->data%2==0)
return(head);
}
2.設計思路
3.本題除錯過程碰到的問題及解決辦法
不是很明白
4.執行結果截圖
第十二周程式設計總結
這個作業屬於那個課程 c語言程式設計2 這個作業要求在 2019年春季學期第十二周作業 我在這個課程的目標是 學會鍊錶的初步使用 這個作業在那個具體方面幫助我實現目標 理解鍊錶 參考文獻 書上鍊表章節 本題要求實現乙個函式,用於計算有n個元素的指標陣列s中最長的字串的長度。函式介面定義 int ma...
第十二周程式設計總結
7 1 程式設計列印空心字元菱形 10 分 本題目要求讀入菱形起始字母和菱形的高度,然後輸出空心字元菱形。所謂 空心菱形 是指 每行由兩端為字母 中間為空格的字串構成,每行的字串中心對齊 上半部分相鄰兩行字串長度差2,且字母從給定的起始字母逐一遞增 下半部分與上半部分對稱。1 實驗 include ...
第十二周程式設計總結
美國 歐巴馬不僅呼籲所有人都學習程式設計,甚至以身作則編寫 成為美國歷史上首位編寫計算機 的 2014年底,為慶祝 電腦科學教育周 正式啟動,歐巴馬編寫了很簡單的計算機 在螢幕上畫乙個正方形。現在你也跟他一起畫吧!1 實驗 include int main printf n return 0 2 設...