Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
54cc91a4e4 | |||
80784eb739 | |||
2c0e314960 | |||
2d0570fdb8 | |||
541d50655c |
18
.vscode/c_cpp_properties.json
vendored
18
.vscode/c_cpp_properties.json
vendored
@ -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
24
.vscode/launch.json
vendored
@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
59
.vscode/settings.json
vendored
59
.vscode/settings.json
vendored
@ -1,59 +0,0 @@
|
||||
{
|
||||
"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
|
||||
}
|
28
.vscode/tasks.json
vendored
28
.vscode/tasks.json
vendored
@ -1,28 +0,0 @@
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++: g++.exe 生成活动文件",
|
||||
"command": "D:\\TDM-GCC\\bin\\g++.exe",
|
||||
"args": [
|
||||
"-fdiagnostics-color=always",
|
||||
"-g",
|
||||
"${file}",
|
||||
"-o",
|
||||
"${fileDirname}\\${fileBasenameNoExtension}.exe"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${fileDirname}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "调试器生成的任务。"
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
77
3.14.cpp
77
3.14.cpp
@ -1,77 +0,0 @@
|
||||
#include<iostream>
|
||||
#include<windows.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
float r,d,C,S;
|
||||
string danwei = "cm";
|
||||
|
||||
int CIN;
|
||||
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;
|
||||
}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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
_此仓库为私人仓库_
|
||||
### Java 分支
|
||||
|
||||
**上课专用**
|
||||
|
||||
编写关于 **Minecraft** 的 _mods_ 和 _plugins_
|
||||
|
3630
SimpleIni.h
3630
SimpleIni.h
File diff suppressed because it is too large
Load Diff
138
change.cpp
138
change.cpp
@ -1,138 +0,0 @@
|
||||
#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为CSSO,1为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
13
class/AB.cpp
@ -1,13 +0,0 @@
|
||||
#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;
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
#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;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
//未知
|
||||
#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;
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
#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;
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
//倒计时
|
||||
|
||||
#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;
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
//奇偶求和
|
||||
|
||||
#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;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
#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;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
//数字矩形
|
||||
#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;
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
#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;
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
#include<iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
|
||||
|
||||
float jg = 4/8 * 100 /2.0;
|
||||
|
||||
cout <<"结果:"<<jg;
|
||||
return 0;
|
||||
}
|
40
sha_lou.cpp
40
sha_lou.cpp
@ -1,40 +0,0 @@
|
||||
//沙漏
|
||||
|
||||
#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
96
system.cpp
@ -1,96 +0,0 @@
|
||||
#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;
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
//正三角形
|
||||
|
||||
#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;
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
//直角三角形
|
||||
#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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user