This commit is contained in:
Dengrb 2024-11-08 22:19:37 +08:00
parent aa0aa62691
commit d3483cf241
9 changed files with 109 additions and 100 deletions

View File

@ -1,18 +0,0 @@
{
"configurations": [
{
"name": "windows-gcc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "D:/TDM-GCC/bin/gcc.exe",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "windows-gcc-x64",
"compilerArgs": [
""
]
}
],
"version": 4
}

24
.vscode/launch.json vendored
View File

@ -1,24 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": true,
"cwd": "c:/Users/Admin/gitee/code",
"program": "c:/Users/Admin/gitee/code/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

60
.vscode/settings.json vendored
View File

@ -1,59 +1,5 @@
{
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false
"files.associations": {
"iostream": "cpp"
}
}

2
.vscode/tasks.json vendored
View File

@ -3,7 +3,7 @@
{
"type": "cppbuild",
"label": "C/C++: g++.exe 生成活动文件",
"command": "D:\\TDM-GCC\\bin\\g++.exe",
"command": "F:\\TDM-gcc\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",

38
homework_new.cpp Normal file
View File

@ -0,0 +1,38 @@
#include<iostream>
#include<string>
#include<windows.h>
using namespace std;
int main(){
string username,password;
string uname,pwd;
username = "2022110";
password = "246810"; //设置密码和用户名
cout <<"欢迎使用登录系统(demo)"<<endl; //无
cout <<"请输入用户名:"; //输入用户名
cin >>uname;
cout <<"请输入密码:";
cin >>pwd;
if (uname == username)
{
if (pwd == password)
{
cout <<"亲爱的小朋友欢迎您!";
Sleep(1000);
return 0;
}else{
cout <<"密码错误!";
Sleep(1000);
return 2;
}
}else{
cout <<"用户名不正确!";
Sleep(1000);
return 1;
}
return 0;
}

43
homework_newplus.cpp Normal file
View File

@ -0,0 +1,43 @@
#include<iostream>
#include<string>
#include<windows.h>
using namespace std;
int main(){
string username,password;
string uname,pwd;
username = "2022110";
password = "246810"; //设置密码和用户名
cout <<"欢迎使用登录系统(demo)"<<endl; //无
for (int time = 3; time > 0;time = time - 1) //反复与计数器
{
int time_out = time -1;
cout <<"请输入用户名:"; //输入用户名
cin >>uname;
cout <<"请输入密码:"; //输入密码
cin >>pwd;
if (uname == username) //验证用户名是否正确
{
if (pwd == password) //验证密码是否正确
{
cout <<"用户名与密码正确!亲爱的小朋友欢迎您!"; //密码与用户名正确的处理
Sleep(1370);
return 0;
}else{
cout <<"密码错误!你还剩下"<<time_out<<"次机会!"<<endl; //密码错误的处理
Sleep(1000);
}
}else{
cout <<"用户名不正确!你还剩下"<<time_out<<"次机会!"<<endl; //用户名错误的处理
Sleep(1000);
}
}
cout <<"尝试次数达到最大!"; //登录次数用完了的处理
Sleep(1000);
return 1;
}

View File

@ -0,0 +1,24 @@
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main() {
double r;
const double PI = 3.14;
cout << "\u8f93\u5165\u534a\u5f84: ";
cin >> r;
if (r < 0 || r > 100) {
cout << "\u8f93\u5165\u9519\u8bef: \u534a\u5f84\u5fc5\u987b\u4e3a0\u5230100\u4e4b\u95f4" << endl;
return 1;
}
double volume = (4.0 / 3) * PI * pow(r, 3);
cout << fixed << setprecision(2);
cout << "\u4f53\u79ef: " << volume << endl;
return 0;
}