基础班day4-上午

This commit is contained in:
flykhan 2023-06-15 11:56:54 +08:00
parent e1bb857fa7
commit ee5c71e2f6
4 changed files with 141 additions and 88 deletions

6
.gitignore vendored
View File

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

13
day4/d2.cpp Normal file
View File

@ -0,0 +1,13 @@
#include <bitset> // 用于使用bitset
#include <iostream>
using namespace std;
int main()
{
cout << "12 = " << 12 << endl; // 结果12
cout << "ob01001 = " << bitset<5>(0b01001) << endl; // 结果9, bitset<8>用于2进制形式输出
cout << "062 = " << 062 << endl; // 结果: 50
cout << "062 = " << oct << 062 << endl; // 结果: 50, oct 用于8进制形式输出
cout << "0x4f = " << hex << 0x4f << endl; // 结果: 79hex 用于16进制形式输出
}

13
day4/exercise_2.4.1.cpp Normal file
View File

@ -0,0 +1,13 @@
#include <bitset> // 用于使用bitset
#include <iostream>
using namespace std;
int main()
{
int x;
x = 52;
cout << "52 的二进制:" << bitset<8>(x) << endl; // bitset<8>用于2进制形式输出, 8表示8位
cout << "52 的八进制:" << oct << x << endl; // oct 用于8进制形式输出
cout << "52 的十六进制:" << hex << x << endl; // hex 用于16进制形式输出
}

21
day4/hello.cpp Normal file
View File

@ -0,0 +1,21 @@
/* ************************************************************************
* Filename: hello.cpp
* Description:
* Version: 1.0
* Created: 20230614 173718
* Revision: none
* Compiler: gcc
* Author: YOUR NAME (liubo),
* Company:
* ************************************************************************/
#include <iostream>
using namespace std;
int main(int argc, char **argv)
{
// 你好c++
cout << "hi, c++" << endl;
return 0;
}