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