2019春第十二周作业

|--------|:------|
|这个作业属于那个课程|C语言程序设计II|
|这个作业要求在哪里|https://edu.cnblogs.com/campus/zswxy/software-engineering-class2-2018/homework/3234|
|我在这个课程的目标是||
|这个作业在那个具体方面帮助我实现目标||
|参考文献||

基础作业

1.函数题:计算最长的字符串长度

用strlen计算类似于求一维数组的最大值
1607302-20190513214518920-1917312457.png

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

2.函数题:统计专业人数

1607302-20190513214627695-1725101160.png

用计数器记录字符串第二三个是否为02就可以了

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

3.函数题:删除单链表偶数结点

翻书仔细看了下才会建立的单链表
1607302-20190513214812015-356200034.png
1607302-20190513214841070-794962552.png

struct ListNode *createlist()
{
    int x;
    struct ListNode *head=NULL,*q=NULL,*p;
    scanf("%d",&x);
    while(x!=-1)
    {
        
        p=(struct ListNode*)malloc(sizeof(struct ListNode));
        p->data=x;
        if(head==NULL)
        head=p;
        else
        q->next=p;
        q=p;
        scanf("%d",&x);
    }
    q=NULL;
    return head;
}
struct ListNode *deleteeven( struct ListNode *head )
{
    struct ListNode *tou=NULL,*p=NULL;
    while(head)
    {
        if(head->data%2!=0)
        {
            if(tou==NULL)
            {
                tou=head;
                p=tou;
            }
            else
            {
                tou->next=head;
                tou=head;
            }
        }
        head=head->next;
    }
    if(tou!=NULL)
    tou->next=NULL;
    return p;
}

转载于:https://www.cnblogs.com/yikejiushidouxing/p/10859261.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值