Compare commits

..

No commits in common. "12e18ec4154db36c350a12836e3db198a37db584" and "b1c38f25c4218d60308ba0d8d5b5aa748345c358" have entirely different histories.

7 changed files with 2 additions and 102 deletions

3
.gitignore vendored
View File

@ -86,10 +86,9 @@ Module.symvers
Mkfile.old
dkms.conf
# 自定义过滤
# 自定义
*/output
*.i
*.s
*.o
*.swp
.vscode

View File

@ -1,15 +0,0 @@
#include <iostream>
using namespace std;
int main()
{
char c = 'a'; // 1B
int m = 2; // 4B
// 小字节转大字节, 会自动转换
m += c; // 先将c转换为int,再相加
cout << "m = " << m << endl;
// 大字节转小字节,会丢失精度,需要强制类型转换
cout << "m to char is " << (char)m << endl;
return 0;
}

View File

@ -1,11 +0,0 @@
#include <iostream>
using namespace std;
int main()
{
cout << "'0' = " << (int)'0' << endl;
cout << 0 << endl;
cout << (int)'\0' << endl;
return 0;
}

View File

@ -1,24 +0,0 @@
#include <iostream>
#include <regex> // 引入正则表达式库
using namespace std;
int main()
{
string x;
cout << "输入一个字符:" << endl;
cin >> x;
regex regex_lower("[a-z]");
regex regex_upper("[A-Z]");
cout << regex_match(x, regex_lower) << regex_match(x, regex_upper) << endl;
// 正则表达式
if (regex_match(x, regex_lower)) // regex_match 匹配正则表达式
{
cout << (char)(x.at(0) - 32) << endl; // .at(0) 获取第一个字符
}
else if (regex_match(x, regex_upper))
{
cout << (char)(x.at(0) + 32) << endl;
}
}

View File

@ -1,24 +0,0 @@
#include <string>
#include <iostream>
using namespace std;
int main()
{
// 字符串打印遇到\0则结束打印
string str1 = "abc\0good"; // abc\0good\0
cout << str1 << str1 << endl;
cout << "sizeof str1 = " << sizeof(str1) << endl; // 32B 32*8=256位
char str2[] = "disen666"; // 字符数组, 实际上也是一个字符串
cout << "str2 = " << str2 << endl;
char str3[] = {'d', 'i', 's', 'e', 'n'}; // 自动添加 '\0'
cout << "str3 = " << str3 << endl;
cout << "sizeof str3 = " << sizeof(str3) << endl; // 5B, 没算 '\0'
string str4 = "a";
cout << "sizeof str4 = " << sizeof(str4) << endl; // 32B 32*8=256位
return 0;
}

View File

@ -1,13 +0,0 @@
#include <iostream>
using namespace std;
int main()
{
int x1, y1, x2, y2;
cout << "请输入两个点坐标, 格式如 x1 y1 x2 y2" << endl;
cin >> x1 >> y1 >> x2 >> y2;
cout << "P1(" << x1 << "," << y1 << ")"
<< " P2(" << x2 << "," << y2 << ")" << endl;
return 0;
}

View File

@ -1,12 +0,0 @@
#include <iostream>
using namespace std;
int main()
{
int a, b;
cout << "输入两个数:" << endl;
cin >> a >> b;
cout << "最大值为: " << (a > b ? a : b) << endl;
return 0;
}