Compare commits

..

4 Commits

Author SHA1 Message Date
054eeb577a 删除.h文件,上传新程序 2025-03-01 10:02:55 +08:00
38b24072f0 update 2025-03-01 09:39:21 +08:00
3a354e7234 数字矩形更新 2025-03-01 09:06:20 +08:00
71fbb44d45 删除加更新 2025-03-01 09:03:04 +08:00
39 changed files with 860 additions and 923 deletions

18
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,18 @@
{
"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 Normal file
View File

@ -0,0 +1,24 @@
{
"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,5 +1,59 @@
{ {
"files.associations": { "C_Cpp_Runner.cCompilerPath": "gcc",
"ostream": "cpp" "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
} }

View File

@ -1,15 +1,77 @@
#include<bits/stdc++.h> #include<iostream>
#include<windows.h>
using namespace std; using namespace std;
int main(){ int main(){
for (int rooster = 1; rooster <= 20; ++rooster) { float r,d,C,S;
for (int hen = 1; hen <= 33; ++hen) { string danwei = "cm";
int chick = 100 - rooster - hen;
if (chick % 3 == 0 && (5 * rooster + 3 * hen + chick / 3) == 100) { int CIN;
cout <<"公鸡: "<<rooster<<" "<<"母鸡: "<<hen<<" "<<"鸡仔: "<<chick<<endl;; cout <<"请输入选项(默认单位cm):"<<endl;
} cout <<"1.面积"<<endl;
} cout <<"2.周长"<<endl;
cout <<"3.改单位"<<endl;
cout <<">>>";
cin >> CIN;
if (CIN == 1)
{
cout <<"请输入半径(若是直径,请留空):";
cin >>r;
if (r==Unknown)
{
cout <<"请输入直径:";
cin >>d;
if (d==Unknown)
{
cout <<"无数据!";
Sleep(2000);
return 1;
} }
r = d/2;
S = r*r*3.14;
cout <<"结果:"<<S<<danwei;
Sleep(2500);
return 0; return 0;
}else
{
S = r*r*3.14;
cout <<"结果是:"<<S<<danwei;
Sleep(2500);
return 0;
}
}else if (CIN == 2)
{
cout <<"请输入直径(若是半径,请留空):";
cin >>d;
if (d==Unknown)
{
cout <<"请输入半径:";
cin >>r;
if (r==Unknown)
{
cout <<"无数据!"<<endl;
Sleep(2000);
return 1;
}else
{
d = r*2;
C = 3.14*d;
cout <<"结果是:"<<C<<danwei;
Sleep(2500);
return 0;
}
}else
{
C = 3.14*d;
cout <<"结果是:"<<C<<danwei<<endl;
return 0;
}
}
} }

3
README.md Normal file
View File

@ -0,0 +1,3 @@
_此仓库为私人仓库_
**上课专用**

138
change.cpp Normal file
View File

@ -0,0 +1,138 @@
#include <iostream>
#include <string>
#include <windows.h>
#include <cstdlib>
#include <fstream>
#include "SimpleIni.h"
using namespace std;
// 函数声明
bool fileExists(const std::string& filename);
bool createDefaultConfig(const std::string& filename);
bool renameFolder(const std::string& oldName, const std::string& newName); // 使用 MoveFile
int main(){
const std::string configFile = "config.ini";
// 检查 config.ini 是否存在
if (!fileExists(configFile)) {
cout << "未检测到 " << configFile << " 文件,正在创建默认配置..." << endl;
if (createDefaultConfig(configFile)) {
cout << "默认配置文件创建成功。" << endl;
} else {
cout << "创建默认配置文件失败。" << endl;
return 1; // 退出程序,因为无法创建配置文件
}
}
// 初始化INI文件
CSimpleIniA ini;
ini.SetUnicode();
ini.SetMultiKey(true);
SI_Error rc = ini.LoadFile(configFile.c_str());
if (rc < 0) {
cout << "无法加载配置文件 " << configFile << endl;
return 1;
}
const char* name = ini.GetValue("User", "name", "0");
cout << "欢迎使用CSSO与CS起源切换程序" << endl;
cout << "当前模式: " << name <<"(0为CSSO1为CS起源)"<< endl;
cout << "请选择操作:" << endl;
cout << "1. CSSO" << endl;
cout << "2. CS起源" << endl;
cout << "3. 退出" << endl;
int choice;
cin >> choice;
if (choice == 1) {
if (strcmp(name, "0") == 0) {
cout << "你已是CSSO模式!" << endl;
} else {
// 切换到CSSO模式
bool result1 = renameFolder("bin", "bin_backup");
bool result2 = renameFolder("bin2", "bin");
if (result1 && result2) {
ini.SetValue("User", "name", "0");
SI_Error saveRc = ini.SaveFile(configFile.c_str());
if (saveRc >= 0) {
cout << "成功切换到CSSO模式!" << endl;
} else {
cout << "保存配置文件失败!" << endl;
}
} else {
cout << "切换失败!检查文件路径或权限。" << endl;
}
Sleep(1500);
}
}
else if (choice == 2) {
if (strcmp(name, "1") == 0) {
cout << "你已是CS起源模式!" << endl;
} else {
// 切换到CS起源模式
bool result1 = renameFolder("bin", "bin2");
bool result2 = renameFolder("bin_backup", "bin");
if (result1 && result2) {
ini.SetValue("User", "name", "1");
SI_Error saveRc = ini.SaveFile(configFile.c_str());
if (saveRc >= 0) {
cout << "成功切换到CS起源模式!" << endl;
} else {
cout << "保存配置文件失败!" << endl;
}
} else {
cout << "切换失败!检查文件路径或权限。" << endl;
}
Sleep(1500);
}
}
else if (choice == 3) {
cout << "退出程序." << endl;
Sleep(100);
return 0;
}
else {
cout << "无效的选项,请重新运行程序并选择正确的选项。" << endl;
}
return 0;
}
// 检查文件是否存在
bool fileExists(const std::string& filename) {
std::ifstream infile(filename);
return infile.good();
}
// 创建默认的config.ini文件
bool createDefaultConfig(const std::string& filename) {
CSimpleIniA ini;
ini.SetUnicode();
ini.SetMultiKey(true);
// 设置默认值
ini.SetValue("User", "name", "0");
// 保存INI文件
SI_Error rc = ini.SaveFile(filename.c_str());
return (rc >= 0);
}
// 使用 MoveFile 重命名文件夹
bool renameFolder(const std::string& oldName, const std::string& newName) {
if (MoveFile(oldName.c_str(), newName.c_str())) {
cout << "重命名成功: " << oldName << " -> " << newName << endl;
return true;
} else {
DWORD error = GetLastError();
cout << "重命名失败: " << oldName << " -> " << newName << " (错误代码: " << error << ")" << endl;
return false;
}
}

13
class/AB.cpp Normal file
View File

@ -0,0 +1,13 @@
#include<iostream>
#include<cmath>
using namespace std;
int main(){
double x1,y1,x2,y2,result;
cin >>x1>>y1>>x2>>y2;
result = sqrt((x1-x2) * (x1-x2) + (y1-y2) * (y1-y2));
cout <<"结果:"<<int(result)<<endl;
}

33
class/calc.cpp Normal file
View File

@ -0,0 +1,33 @@
#include<iostream>
#include<windows.h>
using namespace std;
/*
int main(){
int range = 0;
while (range != 5)
{
int a,s;
cin >>a;
s = a * a;
cout <<"结果:"<<s<<endl;
range++;
}
return 0;
}*/
int main(){
int time = 15;
while (time > 0)
{
cout <<"你还剩"<<time<<"分钟"<<endl;
Sleep(60000);
time--;
}
return 0;
}

21
class/class.cpp Normal file
View File

@ -0,0 +1,21 @@
//未知
#include<iostream>
using namespace std;
int main(){
long long cheng=1,num2,num1;
cout <<"请输入第一个数字:";
cin >>num1;
cout <<"请输第二个数字,每输一个数字,空一格,再输一个数字(Enter结束):";
for (int i = 1; i <= num1; i++)
{
cin >>num2;
cheng *=num2;
}
cout <<cheng<<endl;
return 0;
}

109
class/class_test.cpp Normal file
View File

@ -0,0 +1,109 @@
#include<iostream>
#include<windows.h>
#include <cstdlib>
#include <ctime>
using namespace std;
/*
int main(){
int a,b,c;
cin >>a>>b>>c;
if (a = 1)
{
cout <<"no";
Sleep(1000);
return 0;
}
if ((a+b) > c)
{
cout <<"yes";
Sleep(1000);
return 0;
}else if ((a+c) > b)
{
cout <<"yes";
Sleep(1000);
return 0;
}else if ((b+c) > a)
{
cout <<"yes";
Sleep(1000);
return 0;
}else
{
cout <<"no";
Sleep(1000);
return 1;
}
return 0;
}
int main(){ //三角形判断
int a,b,c;
cin >>a>>b>>c;
if ((a+b > c) && (a+c > b) && (b+c > a))
{
cout <<"yes";
}else
{
cout <<"no";
}
return 0;
}
int main() {
srand(static_cast<unsigned int>(time(nullptr))); // 初始化随机数种子
int random_number = rand() % 5 + 1; // 生成 1 到 5 之间的随机数
cout <<random_number<<endl;
int player_cin;
cout <<"输入你猜的数字,1-5之间"<<endl;
cin >> player_cin;
if (player_cin == random_number)
{
cout <<"恭喜您,中奖了!奖金10元!"<<endl;
return 0;
}else
{
cout <<"没中奖!请付费2元"<<endl;
cout <<"中奖号码是:"<<random_number<<endl;
return 1;
}
return 0;
}
int main(){
int n = 6;
//cin >> n;
int sum = n * (n+1) /2;
cout <<sum;
return 0;
}*/
int main(){
int count = 0;
for (int i = 1; i < 1000; ++i)
{
if (to_string(i).find('3') != string::npos)
{
count++;
}
}
cout <<count<<endl;
return 0;
}

17
class/dao_ji_shi.cpp Normal file
View File

@ -0,0 +1,17 @@
//倒计时
#include<iostream>
#include<windows.h>
using namespace std;
int main(){
for (int i = 15; i > 0; i--)
{
cout <<"距离考试结束还剩:"<<i<<"分钟"<<endl;
Sleep(60000);
}
cout <<"考试结束!"<<endl;
return 0;
}

87
class/hui_wen_shu.cpp Normal file
View File

@ -0,0 +1,87 @@
//do...while
//计算各个数位之和
#include<iostream>
using namespace std;
void while_1();
void do_while();
void huiwenshu();
int main(){
int choose;
cout <<"选择"<<endl;
cout <<"1.do...while"<<endl;
cout <<"2.while"<<endl;
cout <<"3.回文数"<<endl;
cin >>choose;
if (choose == 2)
{
while_1();
}else if (choose == 1)
{
do_while();
}else if (choose == 3)
{
huiwenshu();
}else{
cout <<"输入错误!"<<endl;
}
}
void do_while(){
cout <<"已进入do..while"<<endl;
int CIN,andy;
int a,b,c;
do
{
cin >>CIN;
a = CIN / 100;
b= CIN / 10 % 10;
c = CIN % 10;
andy = a+b+c;
cout <<andy<<endl;
} while (CIN > 0);
}
void while_1(){
cout <<"已进入while"<<endl;
int CIN2,andy,a,b,c;
while (CIN2 > 0)
{
cin >>CIN2;
a = CIN2 / 100;
b = CIN2 / 10 % 10;
b = CIN2 % 10;
andy = a+b+c;
cout <<andy<<endl;
}
}
void huiwenshu(){
while (true)
{
int n,ge,number = 0,number2;
cin >>n;
number2 = n;
do
{
ge = n%10;
number = number * 10 + ge;
n = n / 10;
} while (n > 0);
if (number != number2)
{
cout <<"NO!"<<endl;
}else
{
cout <<"YES!"<<endl;
}
}
}

21
class/ji_shu_qiu_he.cpp Normal file
View File

@ -0,0 +1,21 @@
//奇偶求和
#include<iostream>
using namespace std;
int main(){
int n,sum1=0,sum2=0;
cin >>n;
for (int i = 1; i<=n; i+=2)
{
sum1+=i;
}
for (int i = 2; i <= n; i+=2)
{
sum2+=i;
}
cout <<sum1<<" "<<sum2<<endl;
return 0;
}

21
class/max_and_min.cpp Normal file
View File

@ -0,0 +1,21 @@
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int n;
cin >> n; // 输入整数的个数
int num, min_val;
cin >> num; // 先输入第一个数字,初始化最小值
min_val = num; // 将第一个数字设为初始的最小值
for (int i = 1; i < n; ++i) {
cin >> num; // 输入其余的数字
min_val = min(min_val, num); // 更新最小值
}
cout << min_val << endl; // 输出最小值
return 0;
}

19
class/shu_zi_jv_xin.cpp Normal file
View File

@ -0,0 +1,19 @@
//数字矩形
#include<iostream>
using namespace std;
int main(){
int n;
cin >>n;
for (int i = n-1; i < n; i++)
{
for (int i = 1; i <= n; i++)
{
cout <<"456"<<endl;
}
}
return 0;
}

13
class/test.cpp Normal file
View File

@ -0,0 +1,13 @@
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int a,b,c;
a = 3;
b = 4;
c = a * a + b * b;
cout <<a<<"*"<<a<<"+"<<b<<"*"<<b<<"="<<setprecision(2)<<c<<endl;
return 0;
}

12
class/test1.cpp Normal file
View File

@ -0,0 +1,12 @@
#include<iostream>
using namespace std;
int main(){
float jg = 4/8 * 100 /2.0;
cout <<"结果:"<<jg;
return 0;
}

View File

@ -1,22 +0,0 @@
#include<bits/stdc++.h>
using namespace std;
int main(){
int a = 0,b = 0,c = 0,all = 0;
int n;
cin >>n;
for (int i = 0; i < n; i++)
{
int a1,b1,c1;
cin >>a1>>b1>>c1;
a += a1;
b += b1;
c += c1;
all = a+b+c;
}
cout <<a<<" "<<b<<" "<<c<<" "<<all<<endl;
return 0;
}

View File

@ -1,42 +0,0 @@
/*某邮局对邮寄包裹有如下规定:若包裹的重量超过30千克则不予邮寄对可以邮寄的包裹每件收取手续费0.2元,再加上根据以下收费标准计算的结果。收费标准(元/千克)
()
<=100.8010<<=200.750.7
20<<=30
Fail*/
#include<iostream>
#include<windows.h>
#include<iomanip>
using namespace std;
int main(){
float CIN,money;
cin >>CIN;
if (CIN <= 10)
{
money = CIN * 0.80 + 0.20;
cout <<fixed<<setprecision(2)<<money;
Sleep(2000);
return 0;
}else if (CIN > 10 and CIN <= 20)
{
money = CIN * 0.75 + 0.20;
cout <<fixed<<setprecision(2)<<money;
Sleep(2000);
return 0;
}else if (CIN > 20 and CIN <=30)
{
money = CIN * 0.7 + 0.20;
cout <<fixed<<setprecision(2)<<money;
Sleep(2000);
return 0;
}else
{
cout <<"Fail!";
Sleep(2000);
return 1;
}
return 0;
}

View File

@ -1,40 +0,0 @@
//登录系统(普通)
#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;
}

View File

@ -1,45 +0,0 @@
//登录系统(升级版)
#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

@ -1,73 +0,0 @@
#include<iostream>
#include<windows.h>
using namespace std;
void while_on();
void while_off();
int main(){
cout <<"请选择"<<endl;
cout <<"1.不带循环版"<<endl<<"2.带循环版"<<endl<<"3.退出"<<endl;
cout <<">>>";
int count;
cin >>count;
if (count == 1)
{
while_off();
}else if (count == 2)
{
while_on();
}else if (count == 3)
{
return 0;
}else
{
cout <<"无效的选择!"<<endl;
Sleep(1850);
return 1;
}
return 0;
}
void while_off(){
cout <<"现在模式是 不带循环版"<<endl;
Sleep(1250);
cout <<"请输入一个正整数:";
long long num;
cin >>num;
long long count1 = 0;
do
{
num /= 10;
count1++;
} while (num != 0);
cout <<count1<<endl;
Sleep(2000);
}
void while_on(){
cout <<"现在模式是 带循环版"<<endl;
Sleep(1250);
while (TRUE)
{
cout <<"请输入一个正整数:";
long long num;
cin >>num;
long long count2 = 0;
do
{
num /= 10;
count2++;
} while (num != 0);
cout <<count2<<endl;
Sleep(2000);
}
}

View File

@ -1,59 +0,0 @@
#include<iostream>
#include<windows.h>
using namespace std;
void homework1();
void homework2();
int main(){
int choose;
cout <<"请选择"<<endl;
cout <<"1.输出3的倍数"<<endl;
cout <<"2.未知"<<endl;
cout <<"3.退出"<<endl;
cout <<">>>";
cin >>choose;
if (choose == 1)
{
homework1();
}else if (choose == 2)
{
homework2;
}else if (choose == 3)
{
return 0;
}else
{
cout <<"未知的选项"<<endl;
Sleep(1520);
return 1;
}
return 0;
}
void homework1(){
cout <<"模式 : 1"<<endl;
Sleep(1250);
int n;
cin >> n;
for (int i = 3; i < n; i += 3) {
cout << i << " ";
}
}
void homework2(){
cout <<"模式 : 2"<<endl;
Sleep(1250);
for (char c = 'a'; c <= 'z'; c++) {
cout << c;
}
cout << endl;
for (char c = 'Z'; c >= 'A'; c--) {
cout << c;
}
}

View File

@ -1,20 +0,0 @@
#include<iostream>
using namespace std;
int main(){
int daxie=65,xiaoxie=97;
while (daxie != 91 and xiaoxie != 123)
{
char daxie_1 = daxie;
char xiaaoxie_1 = xiaoxie;
cout <<daxie_1<<xiaaoxie_1;
daxie++;
xiaoxie++;
}
return 0;
}

View File

@ -1,27 +0,0 @@
//猴子吃桃
#include <iostream>
using namespace std;
/*
int main() {
int peaches = 1; // 第10天剩下的桃子数
// 逆推从第10天到第1天
for (int day = 9; day >= 1; --day) {
peaches = (peaches + 1) * 2; // 每天的桃子数量是前一天的剩余加1再乘2
}
cout << "第1天摘的桃子数量是: " << peaches << endl;
return 0;
}
*/
int main(){
int x = 1,day = 9;
while (day > 0)
{
x = (x+1) * 2;
day--;
}
cout <<"共摘了"<<x<<"个桃子"<<endl;
return 0;
}

View File

@ -1,33 +0,0 @@
//计算阶乘
#include <iostream>
using namespace std;
/*
int main() {
int n;
cin >> n; // 输入一个正整数n
long long result = 1; // 使用long long类型来避免结果溢出
// 计算阶乘
for (int i = 1; i <= n; ++i) {
result *= i;
}
cout << result << endl; // 输出阶乘的结果
return 0;
}
*/
int main(){
long long sum = 1;
int n;
cin >>n;
int i = 1;
while (i <= n)
{
sum *= i;
i++;
}
cout <<sum<<endl;
return 0;
}

View File

@ -1,27 +0,0 @@
#include<bits/stdc++.h>
using namespace std;
int main(){
cout <<"提示:最大四位数"<<endl;
int n,num,count = 0;
int a,b,c,d;
cin >>n;
for (int i = 0; i < n; i++)
{
cin >>num;
int a = num / 1000; // 千位
int b = (num % 1000) / 100; // 百位
int c = (num % 100) / 10; // 十位
int d = num % 10; // 个位
if (a+b+c < d)
{
count++;
}
}
cout <<count;
return 0;
}

View File

@ -1,13 +0,0 @@
#include <iostream>
using namespace std;
int main() {
// 遍历1到200的所有数
for (int i = 1; i <= 200; i++) {
// 判断该数是否满足"3721"数的条件
if (i % 3 == 2 && i % 7 == 1) {
cout << i << " "; // 输出满足条件的数
}
}
return 0;
}

View File

@ -1,28 +0,0 @@
#include<iostream>
#include<windows.h>
using namespace std;
int main(){
int tree,wn = 0,clim = 3,time = 0;
cin >> tree;
while (wn < tree)
{
wn += clim;
time ++;
if (wn >= tree)
{
break;
}
wn--;
time++;
}
cout <<"需要"<<time<<" 分钟才能爬到树顶"<<endl;
return 0;
}

View File

@ -1,21 +0,0 @@
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int n;
cin >> n;
double sum = 0.0;
for (int i = 1; i <= n; ++i)
{
sum += 1.0 / i;
}
cout <<fixed<<setprecision(3)<<sum<<endl;
return 0;
}

View File

@ -1,52 +0,0 @@
#include<iostream> //字母位移
using namespace std;
/*
int main(){
char CIN,COUT;
cin >> CIN;
int CIN2 = CIN+=3;
COUT = CIN2;
cout <<COUT;
return 0;
}
int main(){
while (true)
{
char letter;
int n = 3;
cin >>letter;
if (letter >= 'A' && letter <= 'Z') {
char new_letter = (letter - 'A' + n) % 26 + 'A';
cout << new_letter<<endl;
}
}
return 0;
}*/
int main(){
while (true)
{
char ch1,ch2;
int n = 3;
cin >>ch1;
ch2 = ((ch1 -65)+n) %26 +65;
cout <<ch2<<endl;
}
return 0;
}

View File

@ -1,24 +0,0 @@
#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;
}

View File

@ -1,25 +0,0 @@
#include<iostream>
using namespace std;
int main(){
int n,sum=0;
cin >> n;
for (int i = 1; i <= n / 2; i++)
{
if (n % i == 0)
{
sum += i;
}
}
if (sum == n)
{
cout << "YES" << endl;
}
else
{
cout << "NO" << endl;
}
return 0;
}

View File

@ -1,288 +0,0 @@
#include<iostream> //必要头文件
#include<windows.h> //等待头文件
#include<cstdlib> //退出头文件
using namespace std; //设置标准命名空间
void shi_d();
void bai1(); //定义函数
void qian();
void wan();
void shi_wan();
void bai_wan();
void qian_wan();
void yi();
void shi_yi();
int main(){
//选择
cout <<"欢迎使用数字拆分加起来器!"<<endl;
cout <<"选择: 1.十位 2.百位 3.千位 4.万位 5.十万位 6.百万位 7.千万位 8.亿位 9.十亿位 10.退出"<<endl;
cout <<"请输入完成的操作:";
int in;
cin >>in;
if (in==2)
{
bai1();
}else if (in==1)
{
shi_d();
}else if (in==3)
{
qian();
}else if (in==4)
{
wan();
}else if (in==5)
{
shi_wan();
}else if (in==6)
{
bai_wan();
}else if (in==7)
{
qian_wan();
}else if (in==8)
{
yi();
}else if (in==9)
{
shi_yi();
}else if (in==10)
{
return 0;
}else{
cout <<"输入错误!请重新运行程序并输入正确的编号!";
Sleep(1250);
return 1;
}
}
void shi_d(){
//输出
cout <<"现在是十位计算"<<endl;
Sleep(550);
cout <<"请输入一个十位数字(10):";
int number; //输入
cin >>number;
//计算模块
int ge,shi1;
ge = number % 10;
shi1 = number / 10 % 10;
number = ge + shi1;
cout <<"结果为"<<number<<endl; //输出结果
Sleep(1500);
exit(0);
}
void bai1(){
//输入
cout <<"现在是百位计算"<<endl;
Sleep(550);
cout <<"请输入一个百位数字(100):";
int number;
cin >>number;
//计算模块
int ge,shi1,bai;
ge = number % 10;
shi1 = number / 10 % 10;
bai = number / 100;
number = ge + shi1 + bai;
cout <<"结果为:"<<number; //输出结果
Sleep(1500);
exit(0);
}
void qian(){
cout <<"现在是千位计算"<<endl; //输出
Sleep(550);
cout <<"请输入一个千位数字(1000):";
int number; //输入
cin >>number;
int ge,shi,bai,qian; //计算模块
ge = number % 10;
shi = number / 10 % 10;
bai = number / 100 % 10;
qian = number / 1000;
number = ge + shi + bai + qian;
cout <<"结果为:"<<number; //输出结果
Sleep(1500);
exit(0);
}
void wan(){
//输出
cout <<"现在是万位计算"<<endl;
Sleep(550);
cout <<"请输入一个万位数字(10000):";
//输入
int number;
cin >>number;
//计算模块
int ge,shi,bai,qian,wan1;
ge = number % 10;
shi = number / 10 % 10;
bai = number / 100 % 10;
qian = number / 1000 % 10;
wan1 = number / 10000;
number = ge + shi + bai + qian + wan1;
cout <<"结果为:"<<number; //输出结果
Sleep(1500);
exit(0);
}
void shi_wan(){
cout <<"现在是十万位计算"<<endl; //说明
Sleep(550);
cout <<"请输入一个十万位的数字(100000):";
int number; //输入
cin >>number;
//计算模块
int ge,shi,bai,qian,wan,shi_wan1;
ge = number % 10;
shi = number / 10 % 10;
bai = number /100 % 10;
qian = number / 1000 % 10;
wan = number / 10000 % 10;
shi_wan1 = number / 100000;
number = ge + shi + bai + qian + wan + shi_wan1;
//输出结果
cout <<"结果为:"<<number;
Sleep(1500);
exit(0);
}
void bai_wan(){
//说明
cout <<"现在是百万位计算"<<endl;
Sleep(550);
cout <<"请输入一个百万位的数字(1000000):";
int number; //输入
cin >>number;
//计算模块
int ge,shi,bai,qian,wan,shi_wan,bai_wan1;
ge = number % 10;
shi = number / 10 % 10;
bai = number / 100 % 10;
qian = number / 1000 % 10;
wan = number / 10000 % 10;
shi_wan = number / 100000 % 10;
bai_wan1 = number / 1000000;
number = ge + shi + bai + qian + wan + shi_wan + bai_wan1;
//输出结果
cout <<"结果为:"<<number;
Sleep(1500);
exit(0);
}
void qian_wan(){
//说明
cout <<"现在是千万位计算"<<endl;
Sleep(550);
cout <<"请输入一个千万位数字(10000000):";
//输入
int number;
cin >>number;
//计算模块
int ge,shi,bai,qian,wan,shi_wan,bai_wan,qian_wan1;
ge = number % 10;
shi = number / 10 % 10;
bai = number / 100 % 10;
qian = number /1000 % 10;
wan = number / 10000 % 10;
shi_wan = number / 100000 % 10;
bai_wan = number / 1000000 % 10;
qian_wan1 = number / 10000000;
number = ge + shi + bai + qian + wan + shi_wan + bai_wan + qian_wan1;
//输出结果
cout <<"结果为:"<<number;
Sleep(1500);
exit(0);
}
void yi(){
//说明
cout <<"现在是亿位计算"<<endl;
Sleep(550);
cout <<"请输入一个亿位数字(100000000):";
//输入
int number;
cin >>number;
//计算模块
int ge,shi,bai,qian,wan,shi_wan,bai_wan,qian_wan,yi1;
ge = number % 10;
shi = number / 10 % 10;
bai = number / 100 % 10;
qian = number /1000 % 10;
wan = number / 10000 % 10;
shi_wan = number / 100000 % 10;
bai_wan = number / 1000000 % 10;
qian_wan = number / 10000000 % 10;
yi1 = number / 100000000;
number = ge + shi + bai + qian + wan + shi_wan + bai_wan + qian_wan + yi1;
//输出结果
cout <<"结果为:"<<number;
Sleep(1500);
exit(0);
}
void shi_yi(){
//说明
cout <<"现在是十亿位计算"<<endl;
Sleep(550);
cout <<"请输入一个亿位数字(1000000000):";
//输入
int number;
cin >>number;
//计算模块
int ge,shi,bai,qian,wan,shi_wan,bai_wan,qian_wan,yi,shi_yi1;
ge = number % 10;
shi = number / 10 % 10;
bai = number / 100 % 10;
qian = number /1000 % 10;
wan = number / 10000 % 10;
shi_wan = number / 100000 % 10;
bai_wan = number / 1000000 % 10;
qian_wan = number / 10000000 % 10;
yi = number / 100000000 % 10;
shi_yi1 = number / 1000000000;
number = ge + shi + bai + qian + wan + shi_wan + bai_wan + qian_wan + yi;
//输出结果
cout <<"结果为:"<<number;
Sleep(1500);
exit(0);
}

View File

@ -1,74 +0,0 @@
#include <iostream>
using namespace std;
// 函数声明
void qian1(); // 千位计算
void shi11(); // 十位计算
void bai1(); // 百位计算
int main() {
int in;
cout << "1.千位 2.十位 3.百位" << endl;
cin >> in;
// 使用 '==' 进行条件判断
if (in == 1) {
qian1();
} else if (in == 2) {
shi11();
} else if (in == 3) {
bai1();
} else {
cout << "无效输入,请输入1、2或3。" << endl; // 处理无效输入
}
return 0; // 返回0表示程序正常结束
}
void qian1() {
cout << "现在是千数计算" << endl;
int number1, ge1, shi1, bai1, qian1;
cout << "请输入一个四位数: ";
cin >> number1;
// 计算各位数字
ge1 = number1 % 10;
shi1 = (number1 / 10) % 10;
bai1 = (number1 / 100) % 10;
qian1 = number1 / 1000;
// 重新组合数字
number1 = ge1 * 1000 + shi1 * 100 + bai1 * 10 + qian1;
cout << "重新组合后的数字是: " << number1 << endl;
}
void shi11() {
cout << "现在是十数计算" << endl;
int number, ge, shi;
cout << "请输入一个两位数: ";
cin >> number;
// 计算各位数字
ge = number % 10;
shi = number / 10;
// 重新组合数字
number = ge * 10 + shi;
cout << "重新组合后的数字是: " << number << endl;
}
void bai1() {
cout << "现在是百数计算" << endl;
int number, ge, shi, bai;
cout << "请输入一个三位数: ";
cin >> number;
// 计算各位数字
ge = number % 10;
shi = (number / 10) % 10;
bai = number / 100;
// 重新组合数字
number = ge * 100 + shi * 10 + bai;
cout << "重新组合后的数字是: " << number << endl;
}

40
sha_lou.cpp Normal file
View File

@ -0,0 +1,40 @@
//沙漏
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >>n;
int mid = (n - 1) / 2;
for (int i = 0; i < n; i++)
{
int a,b;
if (i <= mid)
{
a = i;
b = n - 2 *i;
}else
{
int j = 2 * mid - i;
a = j;
b = n -2 *j;
}
for (int j = 0; j < a; j++)
{
cout <<" ";
}
for (int y = 0; y < b; y++)
{
cout <<"*";
}
cout <<endl;
}
return 0;
}

96
system.cpp Normal file
View File

@ -0,0 +1,96 @@
#include <windows.h>
#include <shellapi.h>
#include <sddl.h>
#include <tchar.h>
#include <iostream>
#include<string>
using namespace std;
bool IsRunAsAdmin() {
BOOL isAdmin = FALSE;
PSID adminGroup = NULL;
// SID for Administrators group
SID_IDENTIFIER_AUTHORITY ntAuthority = SECURITY_NT_AUTHORITY;
if (AllocateAndInitializeSid(&ntAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &adminGroup)) {
if (!CheckTokenMembership(NULL, adminGroup, &isAdmin)) {
isAdmin = FALSE;
}
FreeSid(adminGroup);
}
return isAdmin == TRUE;
}
void RunAsAdmin() {
TCHAR szPath[MAX_PATH];
if (!GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath))) {
cerr << "Failed to get module file name." << endl;
return;
}
SHELLEXECUTEINFO sei = { sizeof(sei) };
sei.lpVerb = TEXT("runas");
sei.lpFile = szPath;
sei.hwnd = NULL;
sei.nShow = SW_NORMAL;
if (!ShellExecuteEx(&sei)) {
DWORD dwError = GetLastError();
if (dwError == ERROR_CANCELLED) {
cerr << "The user refused to allow elevation." << endl;
} else {
cerr << "ShellExecuteEx failed with error code " << dwError << endl;
}
}
}
int _tmain() {
if (!IsRunAsAdmin()) {
cout << "Program is not running with administrator privileges. Attempting to restart as administrator..." << endl;
RunAsAdmin();
return 0; // Exit the current instance
}
// Your code that requires admin privileges goes here
cout << "Program is running with administrator privileges." << endl;
// Example of code that requires admin privileges
// You can add any code here that needs admin rights
// 例如:修改系统设置、访问受限文件等
extern string choose;
string choose = "";
cout <<"C++ command v1.0"<<endl;
cout <<"https://github.com/dengrb1/"<<endl;
while (choose!="exit")
{
cin >>choose;
if (choose=="list")
{
system("dir");
}else if (choose=="help")
{
cout <<"------------------------------------"<<endl;
cout <<"C++ command帮助菜单"<<endl;
cout <<"注意!本程序区分大小写!"<<endl;
cout <<"list--当前运行环境目录"<<endl;
cout <<"help--帮助菜单"<<endl;
cout <<"cd--加载文件夹"<<endl;
cout <<"------------------------------------"<<endl;
choose = Unknown;
}else{
cout <<choose<<"没有这个指令!"<<endl;
choose = Unknown;
}
}
// Prevent closing immediately to observe behavior
return 0;
}

27
zheng_san_jiao_xin.cpp Normal file
View File

@ -0,0 +1,27 @@
//正三角形
#include<iostream>
#include<windows.h>
using namespace std;
int main(){
int n;
cin >>n;
for (int i = 1; i <= n; i++)
{
for (int y = 1; y <= n-i; ++y)
{
cout <<" ";
}
for (int j = 1; j <= 2*i-1; ++j)
{
cout <<"*";
}
cout <<endl;
}
//Sleep(1000000000);
return 0;
}

22
zhi_jiao_san_jiao_cin.cpp Normal file
View File

@ -0,0 +1,22 @@
//直角三角形
#include<iostream>
#include<string>
using namespace std;
int main(){
int n;
cin >>n;
string xin = "*";
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= i; ++j)
{
cout <<xin;
}
cout <<endl;
}
return 0;
}