C语言(三):字符与运算符

2023-05-26 0 789

C语言(三):字符与运算符

撷取浓厚兴趣,散播欢乐,

快速增长所见所闻,遗留下幸福!

亲爱的您,这儿是LearningYard新辅仁。

那时小编入我们增添的是C词汇(三):数组与操作符。

Share interests, spread happiness,

increase knowledge, and leave good!

Dear you, this is the Learning Yard.

Today, Xiaobian brings you C language (III): characters and operators.

01

数组和数组串

(1)%c相关联数组,%s相关联数组串

(1) % c corresponds to character,% s corresponds to string

(2)ASCII表的利用

(2) Application of ASCII table

C语言(三):字符与运算符

C语言(三):字符与运算符

(3)数组串

①声明数组串:char 变量名[数量]

例如:char name[3](声明3个数组)

②给数组串赋值:(从0开始)

name[0]=p;

name[1]=i;

name[2]=g;

③定义数组串

char name[3]={p,i,g};

多种表示方法:

(3) String

① declaration string: char variable name [quantity] Example: char name [3] (declaration of 3 characters)

② assignment to string: (starting from 0)

name [0]=p;

name[1]=i;

name[2]=g;

③ The definition string char name [3]={p, i, g}; Multiple representations:

C语言(三):字符与运算符

02

算术操作符

(1)%(求余)利用于整数类型

(1) % (remainder) applied to integer type

(2)类型转换

一般将整型转化为浮点型,需要用%f输出

例如:

(2) Type conversion generally converts an integer type to a floating-point type, and requires% f output, for example:C语言(三):字符与运算符

整型输出结果错误,因为计算过程中将1转化为了1.0,需要用浮点型输出

The integer output result is incorrect, because 1 is converted to 1.0 in the calculation process, and the floating-point output is required

(3)强制转换

(3) Cast

C语言(三):字符与运算符

03

关系操作符和逻辑操作符

(1)关系操作符

(1) Relational operators

C语言(三):字符与运算符

例:(1为真,0为假)

Example: (1 is true, 0 is false)

C语言(三):字符与运算符

(2)逻辑操作符

(2) Logical operator

C语言(三):字符与运算符

(3)短路求值

(3) Short-circuit evaluation

C词汇对逻辑与与逻辑或采用短路求值

C language uses short circuit evaluation for logical AND logic or

C语言(三):字符与运算符

对于逻辑与(&&)来说,从左往右判断,同时为真才执行。

对于逻辑或(||)来说,从左往右判断,如果前面有一个表达式为真,就不管后面的表达式。

For logical and (&&), judge from left to right, and execute for real talent at the same time. For logical OR (| |), judge from left to right. If one of the preceding expressions is true, the following expressions are ignored.

END

那时的撷取就到这儿了。

如果您对那时的文章有独特的想法,

欢迎给我们留言,

让我们相约明天,

祝您那时过得开心欢乐!

Thats all for todays sharing.

If you have unique ideas about todays article,

please leave us a message.

Lets meet tomorrow and wish you a happy day!

翻译:百度翻译

参考:《零基础入门学习C词汇:带你学C带你飞》、哔哩哔哩小甲鱼视频、网络图片

声明:本文由LearningYard新辅仁原创,若有侵权请联系删除

文案&排版:易春秀

审核:闫庆红

举报/反馈

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务