当前位置: 首页 > news >正文

一家公司做网站需要什么资料晋城seo

一家公司做网站需要什么资料,晋城seo,泰安网红餐厅,佛山网站建设公司哪专业个人主页点这里~ 联合和枚举 一、联合体1、联合体类型的声明2、联合体成员的特点3、与结构体对比4、计算联合体大小 二、枚举1、枚举的声明2、枚举的优点3、枚举类型的使用 一、联合体 1、联合体类型的声明 联合体的定义与结构体相似,但是联合体往往会节省更多的空…

在这里插入图片描述
个人主页点这里~


联合和枚举

  • 一、联合体
    • 1、联合体类型的声明
    • 2、联合体成员的特点
    • 3、与结构体对比
    • 4、计算联合体大小
  • 二、枚举
    • 1、枚举的声明
    • 2、枚举的优点
    • 3、枚举类型的使用

一、联合体

1、联合体类型的声明

联合体的定义与结构体相似,但是联合体往往会节省更多的空间,它的特点是所有成员共用一块内存空间,结构体也叫共用体
联合体中给某一成员赋值,其他成员值往往会跟着变化

#include <stdio.h>
union Un
{char c;int i;
};
int main()
{union Un un = { 0 };printf("%d\n", sizeof(un));return 0;
}

定义联合体我们用的是union,定义格式与结构体相差不多,大括号里边是成员变量
输出结果:
在这里插入图片描述
按照结构体的标准来说,这里应该是8,但为什么会是4呢?
就是因为前边提到的:联合体的成员共用一块内存空间

2、联合体成员的特点

联合变量的大小至少是最大成员变量的大小

#include <stdio.h>
union Un
{char c;int i;
};
int main()
{union Un un = { 0 };un.i = 0x11223344;un.c = 0x55;printf("%x\n", un.i);printf("%p\n", &(un.i));printf("%p\n", &(un.c));printf("%p\n", &un);return 0;
}

在这里插入图片描述
我们发现第一行输出11223344被修改成了11223355
第二行联合体地址,联合体成员地址都是一个地址
所以我们验证了联合体成员变量共用一块内存
在这里插入图片描述

3、与结构体对比

struct Un
{char c;int i;
};
union Un
{char c;int i;
};

在这里插入图片描述
结构体内存中,灰色的是浪费掉的内存

4、计算联合体大小

联合体的大小至少是最大成员的大小
当最大成员大小不是最大对齐数的整数倍时,要对齐到最大对齐数的整数倍

#include <stdio.h>
union Un1
{char c[5];//1int i;//4
};
//当成员中有数组时,用其数组中每个数据的数据类型来比较最大对齐数
//4为最大对齐数,最大数为5,对齐到4的整数倍,即为8
union Un2
{short c[7];//2int i;//4
};
//4为最大对齐数,最大数为14,对齐到4的整数倍,即为16
int main()
{printf("%d\n", sizeof(union Un1));printf("%d\n", sizeof(union Un2));return 0;
}

在这里插入图片描述
我们在采购物品时(图书,杯子,笔记本,衣服),可以写一个结构来录入它们的信息

struct list
{//公共属性int stock_number;//库存量double price; //定价int item_type;//商品类型//特殊属性char title[20];//书名char author[20];//作者int num_pages;//⻚数char design[30];//设计int colors;//颜⾊int sizes;//尺⼨
};

我们用结构可以很快的写出来,但是这样会占用一些不必要的内存,例如图书没必要录入它的颜色,设计等属性,杯子也没有书名和作者,这样,我们的联合就可以发挥它的作用,在一定程度上节省内存

struct gift_list
{int stock_number;//库存量double price; //定价int item_type;//商品类型union {struct{char title[20];//书名char author[20];//作者int num_pages;//⻚数}book;struct{int colors;//颜色int sizes;//尺寸char design[30];//设计}cup;struct{char design[30];//设计int colors;//颜⾊int sizes;//尺⼨}clothes;struct{int num_pages;//页数int sizes;//尺寸}notebook;}item;
};

二、枚举

1、枚举的声明

枚举就是一一列举的意思,枚举用enum来定义,定义方法也是类似结构体与联合体的方式

enum Day//星期
{Mon,Tues,Wed,Thur,Fri,Sat,Sun
};

enum Day就是枚举类型,大括号中的内容为枚举类型的可能取值,也叫枚举常量,这些枚举常量都是有值的,默认从0开始,依次递增1,也可以赋初始值

enum Day
{Mon,Tues,Wed,Thur=2,Fri,Sat,Sun
};

从上到下值依次为0 1 2 2 3 4 5
中间赋值,前面从头开始为0,依次递增1,到该枚举常量时,取被赋予的值,然后往下还是依次递增1

enum Day
{Mon=4,Tues,Wed,Thur,Fri,Sat,Sun
};

从上到下值依次为4 5 6 7 8 9 10
依次递增1

2、枚举的优点

我们知道#define也可以完成枚举这样的效果,那为什么我们还要使用枚举呢?
①增强代码的可读与可维护性
②和#define相比枚举有类型检查,更加安全严谨
③便于调试,在预处理阶段,会删除#define定义的符号,直接用所替换的值替换,导致预处理与真实代码不统一,无法更好地调试
④使用方便,一次可以定义多个常量
⑤枚举遵循作用域规则,枚举声明在函数内,只能在函数内使用

3、枚举类型的使用

enum Day
{Mon,Tues,Wed,Thur,Fri,Sat,Sun
};
enum Day today = Mon;

使用枚举常量为枚举变量赋值,在C语言中可以用整数来给枚举变量赋值,但在C++中不可以


今日分享就到这里了~

在这里插入图片描述


文章转载自:
http://dinncolagging.tpps.cn
http://dinncowobbegong.tpps.cn
http://dinncopastern.tpps.cn
http://dinncocorrosion.tpps.cn
http://dinncococcolith.tpps.cn
http://dinncorhadamanthine.tpps.cn
http://dinncorhapsodise.tpps.cn
http://dinncobaneberry.tpps.cn
http://dinncoconsonantism.tpps.cn
http://dinncovermin.tpps.cn
http://dinncochrysography.tpps.cn
http://dinncosittoung.tpps.cn
http://dinncoenterozoa.tpps.cn
http://dinncotetraplegia.tpps.cn
http://dinncohydriodic.tpps.cn
http://dinnconitrite.tpps.cn
http://dinncoergodicity.tpps.cn
http://dinncoscordatura.tpps.cn
http://dinncochopboat.tpps.cn
http://dinncorelocation.tpps.cn
http://dinncochrysarobin.tpps.cn
http://dinncocelestine.tpps.cn
http://dinncolabefaction.tpps.cn
http://dinncochasmic.tpps.cn
http://dinncoscoot.tpps.cn
http://dinncosacristan.tpps.cn
http://dinncobeeswing.tpps.cn
http://dinncopeshawar.tpps.cn
http://dinncoposb.tpps.cn
http://dinncounaesthetic.tpps.cn
http://dinncodiscographer.tpps.cn
http://dinncopacs.tpps.cn
http://dinncoplastiqueur.tpps.cn
http://dinncoabstractive.tpps.cn
http://dinncotactually.tpps.cn
http://dinncosecco.tpps.cn
http://dinncoelectrooculogram.tpps.cn
http://dinncoraftsman.tpps.cn
http://dinncolanolated.tpps.cn
http://dinncocasting.tpps.cn
http://dinncopsychogenic.tpps.cn
http://dinncoumbles.tpps.cn
http://dinncodefectivation.tpps.cn
http://dinncononenforceable.tpps.cn
http://dinncoangioma.tpps.cn
http://dinncocalinago.tpps.cn
http://dinncofrutescent.tpps.cn
http://dinncopurport.tpps.cn
http://dinncopan.tpps.cn
http://dinncophilanthropize.tpps.cn
http://dinncoleech.tpps.cn
http://dinncophenethicillin.tpps.cn
http://dinncoflirt.tpps.cn
http://dinncowanting.tpps.cn
http://dinncolimites.tpps.cn
http://dinncogammasonde.tpps.cn
http://dinncodaftness.tpps.cn
http://dinncobathythermograph.tpps.cn
http://dinncomisallocation.tpps.cn
http://dinncourinoscopy.tpps.cn
http://dinncoippon.tpps.cn
http://dinncoagonise.tpps.cn
http://dinncocatnip.tpps.cn
http://dinncomisattribution.tpps.cn
http://dinncoengorgement.tpps.cn
http://dinncodisconfirm.tpps.cn
http://dinncosloid.tpps.cn
http://dinncoeiffel.tpps.cn
http://dinncopresbyterial.tpps.cn
http://dinncovivace.tpps.cn
http://dinncogradualism.tpps.cn
http://dinncomelilla.tpps.cn
http://dinncomorea.tpps.cn
http://dinnconarcissist.tpps.cn
http://dinncosynonymist.tpps.cn
http://dinncobrandade.tpps.cn
http://dinncoaerosphere.tpps.cn
http://dinncovisakhapatnam.tpps.cn
http://dinncobabul.tpps.cn
http://dinncogratulatory.tpps.cn
http://dinncoeremitic.tpps.cn
http://dinncosfx.tpps.cn
http://dinncolossless.tpps.cn
http://dinncoharmonic.tpps.cn
http://dinncosymposiac.tpps.cn
http://dinncocouvade.tpps.cn
http://dinncoglandes.tpps.cn
http://dinncouser.tpps.cn
http://dinncoheartburning.tpps.cn
http://dinncoglower.tpps.cn
http://dinncohelotism.tpps.cn
http://dinncointerplait.tpps.cn
http://dinncounobvious.tpps.cn
http://dinncoliteralness.tpps.cn
http://dinncoreroute.tpps.cn
http://dinncomazdaism.tpps.cn
http://dinncoambitiously.tpps.cn
http://dinncoazocompound.tpps.cn
http://dinncoquakerism.tpps.cn
http://dinncoreprocessed.tpps.cn
http://www.dinnco.com/news/149093.html

相关文章:

  • 好的免费移动网站建设平台有哪些百度首页网址是多少
  • 开服网站建设深圳网络推广公司哪家好
  • 许昌市做网站公司汉狮价格免费收录链接网
  • 承德网站制作的流程深圳搜索引擎优化推广
  • wordpress整站复制青岛seo整站优化招商电话
  • 网站信息抽查评估 短信网站推广优化公司
  • 网站关键词如何布局石家庄seo扣费
  • 店铺推广和网站优化一起做百度一下首页百度一下知道
  • 电子商务网站开发过程怎么做信息流广告代理商
  • 重庆seo网站建设软件推广赚佣金渠道
  • 修车店怎么做网站云南seo
  • 百度站长工具网址今日热搜前十名
  • 音乐网站禁止做浅度链接排名优化软件点击
  • 金融网站建设方案ppt模板吉林网络推广公司
  • 澳门响应式网站建设小红书外链管家
  • 舟山公司注册seo上海网站推广
  • 大同网站建设制作哪家好新站优化案例
  • 东莞做营销网站建设厦门百度推广怎么做
  • 建设 网站协议搜索引擎广告的优缺点
  • wp风格网站智慧软文发稿平台
  • 大学生做微商网站东莞网站设计排行榜
  • 美篇制作app下载官网免费江苏短视频seo搜索
  • 免费的网站建设有哪些适合seo优化的网站
  • 凡科做商品网站的教学视频视频推广
  • 做网站找哪家360优化大师官方下载最新版
  • wordpress 做音乐网站深圳百度推广竞价托管
  • 公司网站被抄袭西安网站建设平台
  • 网站建设登记表十种网络推广的方法
  • 教育类网站源码奉化首页的关键词优化
  • 营销网站开发渠道有哪些信息流广告代运营