日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

十二周+

發布時間:2025/7/14 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 十二周+ 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
這個作業屬于哪個課程C語言程序設計ll
這個作業要求在哪里https://edu.cnblogs.com/campus/zswxy/software-engineering-class2-2018/homework/3234
我在這個課程的目標是掌握指針與函數
這個作業在哪個具體方面幫助我實現目標指針函數的掌握
參考文獻很多大佬代碼

基礎作業

計算最長的字符串長度

函數接口定義: int max_len( char *s[], int n );其中n個字符串存儲在s[]中,函數max_len應返回其中最長字符串的長度。 裁判測試程序樣例: #include <stdio.h> #include <string.h> #include <stdlib.h>#define MAXN 10 #define MAXS 20int max_len( char *s[], int n );int main() {int i, n;char *string[MAXN] = {NULL};scanf("%d", &n);for(i = 0; i < n; i++) {string[i] = (char *)malloc(sizeof(char)*MAXS);scanf("%s", string[i]);}printf("%d\n", max_len(string, n));return 0; }/* 你的代碼將被嵌在這里 */ 輸入樣例: 4 blue yellow red green 輸出樣例: 6

代碼:

int max_len( char *s[], int n ) {int m=0;for(int i=0;i<n;i++){int t=strlen(s[i]);if(m < t){m=t;}}return m; }

流程圖:

運行中遇到的問題:

統計專業人數

本題要求實現一個函數,統計學生學號鏈表中專業為計算機的學生人數。鏈表結點定義如下:

struct ListNode {char code[8];struct ListNode *next; };

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

函數接口定義: int countcs( struct ListNode *head ); 其中head是用戶傳入的學生學號鏈表的頭指針;函數countcs統計并返回head鏈表中專業為計算機的學生人數。 裁判測試程序樣例: #include <stdio.h> #include <stdlib.h> #include <string.h>struct ListNode {char code[8];struct ListNode *next; };struct ListNode *createlist(); /*裁判實現,細節不表*/ int countcs( struct ListNode *head );int main() {struct ListNode *head;head = createlist();printf("%d\n", countcs(head));return 0; }/* 你的代碼將被嵌在這里 */ 輸入樣例: 1021202 2022310 8102134 1030912 3110203 4021205 # 輸出樣例: 3

代碼:

int countcs( struct ListNode *head ) {int num = 0;struct ListNode *p = head;while(p != NULL){if(p->code[1] == '0' && p->code[2] == '2')num++;p = p->next;}return num; }

流程圖

運行中遇到的問題:

一些簡單的編譯錯誤

刪除單鏈表偶數節點

代碼:

struct ListNode *createlist() { int data;struct ListNode *head,*p,*tail;int size=sizeof(struct ListNode);head=p=NULL;scanf("%d",&data);while(data!=-1){p=(struct ListNode*)malloc(size);p->data=data;p->next=NULL;if(head==NULL)head=p;elsetail->next=p;tail=p;scanf("%d",&data);} return head;} struct ListNode *deleteeven( struct ListNode *head ) {struct ListNode *p1,*p2;while(head!=NULL&&head->data%2==0){p2=head;head=head->next;free(p2);}if(head==NULL)return NULL;p1=head;p2=head-> next;while(p2!=NULL){if(p2->data%2==0){p1->next=p2->next;free(p2);}elsep1=p2;p2=p1->next;}return head; }

這個是查的沒有思路

學習總結:

上了兩節課,都不是很明白,完成作業也有一些問題,勉勉強強

編程總結:

討論了一些思路,檢查了下代碼,還行。
| 周 | 學習天數 | 代碼行數 | 知識點 | 疑惑點 |
| ----- | ------------ | ------------ | --------- | --------- |
| 十二 | 兩天 | 93 | 指針與函數 | 一些思路問題 |

轉載于:https://www.cnblogs.com/xulongfei/p/10883271.html

總結

以上是生活随笔為你收集整理的十二周+的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。