day03
谁能横刀立马,唯我飞牛大将军!
小细节:【在VS编译器中,输入函数有两种写法:scanf_s和#pragma warning(disable : 4996)】 scanf
下面是day02所学到的知识:
涵盖知识点:
转义字符的考查
选择语句(if部分)
循环语句初步
函数初步
变量地址的有趣现象
注:<1>本节为初步内容,后续更新详细知识与例题精讲。
<2>此部分没有过多定义及语法,所以直接例题,简单粗暴。
1.
接day02转义字符
给出一个例子:
2.
选择语句
(1)if(表达式){ 语句; }
(2if(表达式){语句1;} else{语句2;}
(3)if(表达式1){语句1;} else if(表达式2){语句2;} else{语句3;}
//小技巧:这么写可以看起来更专业,也方便检查错
if(1 == select){
printf("OK!");
}
else if(2 == select){
printf("不OK!");
}
else{
printf("很OK!");
}
3.
循环语句
(1)while循环
(2)for语句
(3)do while语句
4.函数
#include <stdio.h>
#include<windows.h>
#pragma warning(disable : 4996)
int MAX(int _x, int _y)
{
int c = 0;
if (_x> _y)
{
c = _x;
return c;
}
else if (_x <_y)
{
c = _y;
return c;
}
else{
c = _x;
return c;
}
}
int main()
{
int a = 0;
int b = 0;
int c = 0;
printf("请输入两个数字:");
scanf("%d%d", &a, &b);
c = MAX(a, b);
printf("%d\n", c);
system("pause");
return 0;
}
5.这个很有趣,拿出来分享一下