6.27-6.29 旧c语言

#include<stdio.h>
struct stu
{
    int num;
    float score;
    struct stu *next;
};
void main()
{
    struct stu a,b,c,*head;//静态链表
    a.num = 1;
    a.score = 10;
    b.num = 2;
    b.score = 20;
    c.num = 3;
    c.score = 30;
    head = &a;
    a.next = &b;
    b.next = &c;
    do
    {
        printf("%d,%5.1f\n",head->num,head->score);
        head = head->next;
    }while(head != NULL);
}

在这里插入图片描述
在这里插入图片描述

#include<stdio.h>
#include<stdlib.h>
#define LEN sizeof(struct stu)
int n;
struct stu
{
    int num;
    float score;
    struct stu *next;
};
struct stu *creat()//建立动态链表
{
    struct stu *p1,*p2,*head;
    p1 = p2 = (struct stu *)malloc(LEN);
    printf("input num:\n");
    scanf("%d",&p1->num);
    printf("input score:\n");
    scanf("%f",&p1->score);
    head = NULL,n = 0;
    while(p1->num != 0)
    {
        n++;
        if(n == 1)
        {
            head = p1;
        }
        else
        {
            p2->next = p1;
        }
        p2 = p1;//
        p1 = (struct stu *)malloc(LEN);
        printf("input num:\n");
        scanf("%d",&p1->num);
        printf("input score:\n");
        scanf("%f",&p1->score);
    }
    p2->next = NULL;
    return head;

}
void print(struct stu *head)
{
    struct stu *p;
    printf("there are %d record stu\n",n);
    p = head;
    if(head != NULL)
    {
        do
        {
            printf("num = %d,score = %f\n",p->num,p->score);
            p = p->next;
        }while(p);//直到p为空结点退出循环
    }
}
void main()
{
    struct stu *p;
    p = creat();
    print(p);
}

在这里插入图片描述

#include<stdio.h>//增删改查
#include<stdlib.h>
#define LEN sizeof(struct stu)
struct stu *del(struct stu *head,int n);
struct stu *creat();
void print(struct stu *head);
int n;
struct stu
{
    int num;
    float score;
    struct stu *next;
};
struct stu *del(struct stu *head,int m)
{
    struct stu *p1,*p2;
    p1 = head;
    if(head == NULL)//判断是否为空链表
    {
        printf("this is kong node\n");
        return NULL;
    }
    while(p1->num != m && p1->next != NULL)//删除的值不是当前结点,且当前结点不为尾节点
    {
        p2 = p1;
        p1 = p1->next;
    }
    if(p1->num == m)//找到节点
    {
        if(p1 == head)//如果当前节点为头结点
        {
            head = p1->next;
        }
        else//此时为普通结点
        {
            p2->next = p1->next;
        }
        printf("del NO:%d success!\n",m);
        n = n-1;
    }
    else
    {
        printf("%d no found!\n",n);
    }
    return head;
}
struct stu *creat()
{
    struct stu *p1,*p2,*head;
    p1 = p2 = (struct stu *)malloc(LEN);
    printf("input num:\n");
    scanf("%d",&p1->num);
    printf("input score:\n");
    scanf("%f",&p1->score);
    head = NULL,n = 0;
    while(p1->num != 0)
    {
        n++;
        if(n == 1)
        {
            head = p1;
        }
        else
        {
            p2->next = p1;
        }
        p2 = p1;
        p1 = (struct stu *)malloc(LEN);
        printf("input num:\n");
        scanf("%d",&p1->num);
        printf("input score:\n");
        scanf("%f",&p1->score);
    }
    p2->next = NULL;
    return head;

}
void print(struct stu *head)
{
    struct stu *p;
    printf("there are %d record stu\n",n);
    p = head;
    if(head != NULL)
    {
        do
        {
            printf("num = %d,score = %f\n",p->num,p->score);
            p = p->next;
        }while(p);
    }
}
void main()
{
    struct stu *stu,*p;
    int k;
    stu = creat();
    p = stu;
    print(p);
    printf("del num is:\n");
    scanf("%d",&k);
    print(del(p,k));
}

在这里插入图片描述
在这里插入图片描述

#include<stdio.h>
#include<stdlib.h>
#define LEN sizeof(struct stu)
struct stu *del(struct stu *head,int n);
struct stu *creat();
void print(struct stu *head);
struct stu *inser(struct stu *head,struct stu *ins);
struct stu *lookfor(struct stu *head,struct stu *look);
struct stu *wrilink(struct stu *head,struct stu *stu4);
struct stu
{
    int num;
    float score;
    struct stu *next;
};
int n;
struct stu *wrilink(struct stu *head,struct stu *stu4)
{
    struct stu *p;
    p = head;
    if(head == NULL)
    {
        printf("无数据可修改!\n");
    }
    else
    {
        while(p != NULL)
        {
            if(p->num == stu4->num)
            {
                p->score = stu4->score;
            }
            p = p->next;
        }
    }
    return head;
}
struct stu *lookfor(struct stu *head,struct stu *look)
{
    struct stu *p;
    p = head;
    if(p == NULL)
    {
        printf("没有数据!\n");
    }
    else
    {
        while(p != NULL)
        {
            if(p->num == look->num)
            {
                printf("找到第%d个数据,分数为%f\n",p->num,p->score);
            }
            p = p->next;
        }
    }
    return head;
}
struct stu *inser(struct stu *head,struct stu *ins)
{
    struct stu *p1,*p2,*p0;
    p0 = ins;
    p1 = head;
    if(head == NULL)
    {
        head = p0;
        p0->next = NULL;
    }
    else
    {
        while((p0->num >p1->num) && (p1->next != NULL))
        {
            p2 = p1;
            p1 = p1->next;
        }
        if(p0->num <= p1->num)
        {
            if(p1 == head)
            {
                head = p0;
            }
            else
            {
                p2->next = p0;
            }
            p0->next = p1;
        }
        else
        {
            p1->next = p0;
            p0->next = NULL;
        }
        n = n+1;
        return head;
    }
}
struct stu *del(struct stu *head,int m)
{
    struct stu *p1,*p2;
    p1 = head;
    if(head == NULL)
    {
        printf("this is kong node\n");
        return NULL;
    }
    while(p1->num != m && p1->next != NULL)
    {
        p2 = p1;
        p1 = p1->next;
    }
    if(p1->num == m)
    {
        if(p1 == head)
        {
            head = p1->next;
        }
        else
        {
            p2->next = p1->next;
        }
        printf("del NO:%d success!\n",m);
        n = n-1;
    }
    else
    {
        printf("%d no found!\n",n);
    }
    return head;
}
struct stu *creat()
{
    struct stu *p1,*p2,*head;
    p1 = p2 = (struct stu *)malloc(LEN);
    printf("input num:\n");
    scanf("%d",&p1->num);
    printf("input score:\n");
    scanf("%f",&p1->score);
    head = NULL,n = 0;
    while(p1->num != 0)
    {
        n++;
        if(n == 1)
        {
            head = p1;
        }
        else
        {
            p2->next = p1;
        }
        p2 = p1;
        p1 = (struct stu *)malloc(LEN);
        printf("input num:\n");
        scanf("%d",&p1->num);
        printf("input score:\n");
        scanf("%f",&p1->score);
    }
    p2->next = NULL;
    return head;

}
void print(struct stu *head)
{
    struct stu *p;
    printf("there are %d record stu\n",n);
    p = head;
    if(head != NULL)
    {
        do
        {
            printf("num = %d,score = %f\n",p->num,p->score);
            p = p->next;
        }while(p != NULL);
    }
}
void main()
{
    struct stu *stu,*p,stu2,stu3,stu4;
    int k;
    stu = creat();
    p = stu;
    print(p);
    printf("del num is:\n");
    scanf("%d",&k);
    print(del(p,k));
    printf("insert into the num:");
    scanf("%d",&stu2.num);
    printf("insert into the score:");
    scanf("%f",&stu2.score);
    p = inser(stu,&stu2);
    print(p);
    printf("请输入查找的数据是:");
    scanf("%d",&stu3.num);
    lookfor(stu,&stu3);
    printf("请输入修改的学号:");
    scanf("%d",&stu4.num);
    printf("请输入修改的学号数据:");
    scanf("%f",&stu4.score);
    p = wrilink(stu,&stu4);
    print(p);
}


typedef 声明新的类型名来代替已有的类型名,有利于程序通用与移植

#include<stdio.h>
typedef struct
{
    int year;
    int month;
    int day;
}date;
void main()
{
    date da;
    da.year = 1995;
    da.month = 8;
    da.day = 9;
    printf("%d--%d--%d\n",da.year,da.month,da.day);
}

#include<stdio.h>
typedef int num[100];//声明um为整型数组类型
void main()
{
  num n = {0};
  printf("%d\n",sizeof(n));
}

#include<stdio.h>
typedef void (*p)();
void fun()
{
    printf("funny\n");
}
void main()
{
    p p1;
    p1 = fun;//函数指针指向函数的入口
    p1();
}

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/758404.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Cesium Model 中的剪裁平面 (ClippingPlane)

Cesium Model 中的剪裁平面 (ClippingPlane) 参考: https://www.cnblogs.com/webgl-angela/p/9197672.html Cesium Model 中的剪裁平面 (ClippingPlane) // 相关类: class ClippingPlaneCollection {} class ClippingPlane {}// 剪裁的整体流程: Model.prototype.update () …

LINGO:生产计划问题

模型&#xff1a;有瓶颈设备的多级生产计划问题 某工厂的主要任务是通过组装生产产品 A &#xff0c;用于满足外部市场需求。产品 A 的构成与组装过程见下图 &#xff0c;即 D , E , F , G 是从外部采购的零件&#xff0c;先将零件 D , E 组装成部件 B &#xff0c;零…

看你那样,超出你想像:羊、羊、羊

一、I am me,羊羊羊英文中的 我就是我(I am me),其实就是:羊 羊 羊,为什么会有这么一个结论呢?请往下看:I,就是羊am(是),也是羊me(我),还是羊我就是我,不一样的烟火。其实,我就是我(I am me),没有什么不一样,因为全是羊。二、羊都一样吗?among(在...当中…

斜率优化DP——AcWing 303. 运输小猫

斜率优化DP 定义 斜率优化DP&#xff08;Slope Optimization Dynamic Programming&#xff09;是一种高级动态规划技巧&#xff0c;用于优化具有特定形式的状态转移方程。它主要应用于那些状态转移涉及求极值&#xff08;如最小值或最大值&#xff09;的问题中&#xff0c;通…

c++重载(运算符)

1&#xff09;C入门级小知识&#xff0c;分享给将要学习或者正在学习C开发的同学。 2&#xff09;内容属于原创&#xff0c;若转载&#xff0c;请说明出处。 3&#xff09;提供相关问题有偿答疑和支持。 对于系统的所有操作符&#xff0c;一般情况下&#xff0c;只支持基本数…

ubuntu安装显卡驱动

获取权限 chmod X NVIDlA-Linux-x86_64-550.90.07.run 安装程序 sudo bash NVIDlA-Linux-x86_64-550.90.07.run

告别模糊时代,扫描全能王带来清晰世界

模糊碑文引发的思考 上个月中旬去洛阳拜访了著名的龙门石窟&#xff0c;本就对碑文和文字图画感兴趣的我们&#xff0c;准备好好欣赏一下龙门石窟的历史文化古迹。到了地方之后&#xff0c;我发现石窟的高度和宽度远远超出了想象&#xff0c;正因如此&#xff0c;拍出来的文字…

多多代播24小时值守:电商直播时代是带货爆单的关键

在电商直播盛行的今天&#xff0c;直播带货已成为品牌与消费者沟通的关键。然而&#xff0c;流量波动大&#xff0c;竞争激烈&#xff0c;使品牌面临诸多挑战。因此&#xff0c;许多品牌寻求专业代播服务&#xff0c;并特别强调24小时值守的重要性。 流量来源的不稳定性是一个显…

Spring-循环依赖是如何解决的

1、bean被创建保存到spring容器的过程 1、实例化 -> 获取对象&#xff1b; 2、填充属性&#xff1b;这里可能需要依赖其它的bean。 3、AOP代理对象替换&#xff1b; 4、加入单例池&#xff1b; 问题&#xff1a; 循环依赖怎么处理 ServiceA 中有属性ServiceB b&#…

使用label-studio对OCR数据进行预标注

导读 label-studio作为一款数据标注工具相信大家都不陌生&#xff0c;对于需要进行web数据标注协同来说应该是必备工具了&#xff0c;标注的数据类型很全涉及AI的各个任务(图像、语音、NLP、视频等)&#xff0c;还支持自定义涉及模版。 然而&#xff0c;我们在标注数据的过程…

win11 内存占用过大优化尝试

关闭开机加速 wins打开搜索 控制面板&#xff0c;打开控制面板 找到硬件和声音-电源选项-选择电源按钮的功能-去掉勾选启用快速启动 关闭windows 更新 winr 输入services.msc打开服务-搜索windows 更新-双击打开设置-选择禁用 貌似没什么用。

【Python3的内置函数和使用方法】

目录 Python 特点 Python 中文编码 Python 变量类型 Python列表 Python 元组 元组是另一个数据类型&#xff0c;类似于 List&#xff08;列表&#xff09; Python 字典 Python数据类型转换 Python 运算符 Python算术运算符 Python比较运算符 Python赋值运算符 Pyt…

根据描述表示泥浆密度沿着管路的长度方向在不断变化,如何来表示泥浆密度随管路的变化?

&#x1f3c6;本文收录于《CSDN问答解答》专栏&#xff0c;主要记录项目实战过程中的Bug之前因后果及提供真实有效的解决方案&#xff0c;希望能够助你一臂之力&#xff0c;帮你早日登顶实现财富自由&#x1f680;&#xff1b;同时&#xff0c;欢迎大家关注&&收藏&…

文件夹内-资源名称前加序号排列

问题&#xff1a;在文件夹下的资源可以按时间排序&#xff0c;导入unity后资源顺序会乱掉&#xff0c;不方便按顺序赋值&#xff0c;为了方便&#xff0c;通过下面方法在文件夹下统一在资源名称前按顺序加上序号 win11在文件夹内右键&#xff0c;选择——在终端中打开 输入&a…

4.SQL注入-xx型

SQL注入-xx型 输入kobe查询&#xff0c;同样展示id和邮箱 xx型的sql语句查询方式&#xff0c;猜测 select 字段1,字段2 from 表名 where username(kobe)在后台语句中的查询 select id,email from member where username(kobe);根据上图构造payload语句为 username(kobe) …

spring-security安全框架(超精细版附带流程讲解图)

目录 一、回顾一下 二、security使用 2.1 覆盖掉默认配置「自定义配置」 2.2 如何自定义认证 2.3 纯纯自定义 2.4 jwt 2.5 官网认证流程 2.6 RBAC模型 4.1. 创建表结构 2.7 如何实现权限流程 一、回顾一下 security干啥的? 认证和授权 使用方式 引入依赖, 基于spri…

【自然资源】国家历史文化名城你知道多少?

【自然资源】国家历史文化名城你知道多少&#xff1f; 中国五千年的历史孕育出了一些因深厚的文化底蕴和发生过重大历史事件而青史留名的城市。根据《中华人民共和国文物保护法》&#xff0c;“历史文化名城”是指保存文物特别丰富&#xff0c;具有重大历史文化价值和革命意义…

小红书多账号管理平台哪个好用?可以快速监测多个小红书账号的数据吗?

随着品牌营销战线的不断扩展&#xff0c;小红书已经成为企业和个人品牌竞相展示的舞台。但是&#xff0c;随之而来的多账号管理问题也让众多运营者头疼不已。一个优秀的多账号管理平台&#xff0c;能让你事半功倍&#xff0c;轻松监控和分析账号数据。 如今&#xff0c;市面上出…

昇思25天学习打卡营第12天 | ResNet50图像分类

内容介绍&#xff1a; ResNet50网络是2015年由微软实验室的何恺明提出&#xff0c;获得ILSVRC2015图像分类竞赛第一名。在ResNet网络提出之前&#xff0c;传统的卷积神经网络都是将一系列的卷积层和池化层堆叠得到的&#xff0c;但当网络堆叠到一定深度时&#xff0c;就会出现…

NPOI入门指南:轻松操作Excel文件的.NET库

目录 引言 一、NPOI概述 二、NPOI的主要用途 三、安装NPOI库 四、NPOI基本使用 六、性能优化和内存管理 七、常见问题与解决方案 八、结论 附录 引言 Excel文件作为数据处理的重要工具&#xff0c;广泛应用于各种场景。然而&#xff0c;在没有安装Microsoft Office的…