基础班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

182
.gitignore vendored
View File

@ -1,88 +1,94 @@
# ---> C++
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
# ---> C
# Prerequisites
*.d
# Object files
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su
*.idb
*.pdb
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
# ---> C++
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
# ---> C
# Prerequisites
*.d
# Object files
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su
*.idb
*.pdb
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
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;
}