本文代码仓库地址: gitee码云笔记仓库地址
源文件:Hello_World.cpp
#include <iostream>
using namespace std
;
#include <string>
#include <cstdlib>
#include <ctime>
int main() {
int a
= 1;
cout
<< a
<< endl
;
cout
<< "int类型的内存大小:" << sizeof(int) << endl
<< endl
;
cout
<< "变量 a 的内存大小:" << sizeof(a
) << endl
;
cout
<< endl
;
cout
<< endl
;
cout
<< "请输入 int 类型的值:";
cin
>> a
;
cout
<< "您输入的值为:" << a
<< endl
;
bool fol
= false;
cout
<< "请输入 bool 类型的值";
cin
>> fol
;
cout
<< "布尔类型 非0即为真,您输入的为:" << fol
<< endl
;
if (fol
)
{
cout
<< "是True就进来我这个里面" << endl
;
}
else
{
cout
<< "是False就进来我这个里面" << endl
;
}
cout
<< endl
;
switch (a
)
{
case 0:
cout
<< "我是0的入口" << endl
;
break;
case 1:
cout
<< "我是1的入口" << endl
;
break;
case 2:
cout
<< "我是2的入口" << endl
;
break;
case 3:
cout
<< "我是3的入口" << endl
;
break;
default:
cout
<< "我是最后不满足的出口哦" << endl
;
break;
}
int i
= 0;
while (i
< 5)
{
cout
<< i
<< endl
;
i
++;
}
int num01
= rand() % 100;
cout
<< num01
<< endl
;
srand((unsigned int) time(NULL));
num01
= rand() % 100;
cout
<< num01
<< endl
;
do
{
cout
<< num01
<< "我是 do ... while ..." << endl
;
num01
= num01
+ 10;
} while (num01
< 100);
for (int i
= 100; i
< 1000; i
++)
{
int digits
= i
% 10;
int tens
= (i
/ 10) % 10;
int hundreds
= i
/ 100;
int sum
= digits
* digits
* digits
+ tens
* tens
* tens
+ hundreds
* hundreds
* hundreds
;
if (i
== sum
)
{
cout
<< i
<< "是水仙花数" << endl
;
}
}
for (int i
= 1; i
< 11; i
++)
{
if (i
% 2 == 0)
{
cout
<< i
<< ":我是10以内的偶数";
}
else
{
continue;
}
cout
<< ",妙啊~" << endl
;
}
goto FLAG
;
cout
<< "某些代码!!!" << endl
;
cout
<< "某些代码!!!" << endl
;
FLAG
:
cout
<< "下面的代码!!" << endl
;
cout
<< "下面的代码!!" << endl
;
system("pause");
return 0;
}
rand() 伪随机数 开始都是41 int num01 = rand() % 61; 随机数的值为0 ~ 60 int num01 = rand() % 61 + 40; 随机数的值为40 ~ 100
在任何地方使用 exit(0); 系统都会直接退出 system(“cls”); 清屏 strlen(ch); 获取有效长度
一点点笔记,以便以后翻阅。