删除加更新

This commit is contained in:
Dengrb 2025-03-01 09:03:04 +08:00
parent 7dbdfd5b1c
commit 71fbb44d45
18 changed files with 21 additions and 864 deletions

View File

@ -1,3 +1,4 @@
//未知
#include<iostream>
using namespace std;

20
class/shu_zi_jv_xin.cpp Normal file
View File

@ -0,0 +1,20 @@
//数字矩形
#include<bits/stdc++.h>
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;
}

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,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,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,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,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;
}