作业头
这个作业属于那个课程 | C语言程序设计II |
---|---|
这个作业要求在哪里 | https://edu.cnblogs.com/campus/zswxy/software-engineering-class1-2018/homework/3235 |
我在这个课程的目标是 | 掌握(1)二级指针的概念,以及指针数组的应用;(2)了解指针与函数的关系,掌握指针作为函数返回值;(3)掌握单向链表的概念和操作(建立、增加、删除、修改、遍历) |
这个作业在那个具体方面帮助我实现目标 | 使用单向链表解决问题 |
参考文献 | 教材 |
参考文献 | 字符函数 |
本题要求实现一个函数,用于计算有n个元素的指针数组s中最长的字符串的长度。
函数接口定义:
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 20
int 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
", 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;
}
流程图:
编程截图:
总结:
这题因为前面有过类似的题目所以做起来还有点思路
这个作业属于那个课程|C语言程序设计II
-|-|-
这个作业要求在哪里|要求
我在这个课程的目标是|灵活调用函数
这个作业在哪个具体方面帮助我实现目标|使用函数解决问题
参考文献|字符函数
实验代码:
---
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;
}
流程图:
编程截图:
总结:
这题相对这周的作业来说没那么难了