首页
关于
Search
1
python初学示例
563 阅读
2
欢迎使用 Typecho
528 阅读
3
晒谷子
507 阅读
4
痛
491 阅读
5
蓝桥杯2022年第十三届省赛真题-X进制减法
476 阅读
默认分类
登录
Search
Typecho
累计撰写
36
篇文章
累计收到
10
条评论
首页
栏目
默认分类
页面
关于
搜索到
36
篇与
admin
的结果
2023-02-03
2022蓝桥杯(c/c++ B组)-刷题统计
小明决定从下周一开始努力刷题准备蓝桥杯竞赛。他计划周一至周五每天做 a 道题目,周六和周日每天做 b 道题目。请你帮小明计算,按照计划他将在第几天实现做题数大于等于 n 题?输入格式输入一行包含三个整数 a, b 和 n.输出格式输出一个整数代表天数。样例输入10 20 99样例输出8提示对于 50% 的评测用例,1 ≤ a, b, n ≤ 106 . 对于 100% 的评测用例,1 ≤ a, b, n ≤ 1018 分析 我们可以确定一个星期为7天,且五天做的题数为5*a,周末为2*b输入为一个n,用sum=n/(5*a+2*b)得出用了多少周,剩余题量为count=n-sum*(sum*5*a+sum*2*b);sum=sum*7所得天数剩余题量是在一个星期内肯定能完成我们可以用两个for循环解决for(int i=0;i<5&&count>0;i++) sum+=1,count-=a;for(int i=0;i<2&&count>0;i++) sum+=1,count-=b;最后输出sum即可 对于数据范围要用long long 不然第71个数据直接报错 代码:#include<iostream> using namespace std; int main() { long long a,b,n,count; long long sum=0; cin>>a>>b>>n; sum=n/(5*a+2*b); count = n-sum*(5*a+2*b); sum=sum*7; for(int i=0;i<5&&count>0;i++) sum+=1,count-=a; for(int i=0;i<2&&count>0;i++) sum+=1,count-=b; cout<<sum<<endl; }有错误请指出,蟹蟹;
2023年02月03日
162 阅读
0 评论
0 点赞
2023-01-27
腾讯云开发者平台入驻
腾讯云开发者平台入驻我的博客即将同步至腾讯云开发者社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan?invite_code=5e986vqayuap
2023年01月27日
138 阅读
0 评论
0 点赞
2022-09-23
Vscode使用基础
首先下载code runnner 并安装;打开设置勾选run in rerminal搜索encoding 换成GB2312格式,以便防止中文乱码输出;创建一个lunch.json文件并将一下代码修改并复制进去{ // 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。 // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "gcc.exe - 生成和调试活动文件", "type": "cppdbg", "request": "launch", "program": "${fileDirname}\\${fileBasenameNoExtension}.exe", "args": [], "stopAtEntry": false, "cwd": "${fileDirname}", "environment": [], "externalConsole": true,//是否使用外部控制台 "MIMode": "gdb", "miDebuggerPath": "C:\\cenvirment\\MinGW\\bin\\gdb.exe",//此处填写gdb.exe的路径 "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "preLaunchTask": "C/C++: gcc.exe 生成活动文件" } ] }miDebuggerPath的值就是你的bin路径列子:"miDebuggerPath": "路径\Bin\gdb.exe"修改之后保存即可设置完成
2022年09月23日
229 阅读
0 评论
1 点赞
2022-06-22
职员管理系统
main.cpp的内容#include"add.h" #include<iostream> #include<string> #include<algorithm> #include<fstream> #include<stdlib.h> using namespace std; void CreatAdmin(); int main() { char Choice; string UserName,PassWord; string InputUserName,InputPassWord; ifstream fin("admin.dat",ios::in); if(!fin) { cout<<"还未创建admin用户,请创建"; CreatAdmin(); fin.close(); } fin.close(); fin.open("admin.dat",ios::in); fin>>UserName; fin>>PassWord; cout<<"请输入admin用户名"<<endl; cin>>InputUserName; cout<<"请输入admin密码"<<endl; cin>>InputPassWord; if(UserName==InputUserName && InputPassWord==PassWord) { system("cls"); cout<<"已进入系统!"<<endl; PrintWlecome(UserName); cin>>Choice; while (1) { JusticeUsersChoice(Choice); system("color 04"); cout<<"请选择操作\n1.存入信息\n2.删除信息\n3.查找信息\n4.遍历信息\n5.修改信息"<<endl; cin>>Choice; } } else{ cout<<"用户名或者密码不正确"<<endl; exit(0); } system("pause"); } void CreatAdmin() { string UserName,PassWord; ofstream fout("admin.dat",ios::out|ios::binary); cout<<"请输入admin用户名"<<endl; cin>>UserName; cout<<"请输入admin密码"<<endl; cin>>PassWord; fout<<UserName<<" "<<PassWord; fout.close(); system("cls"); }add.h的内容#include<iostream> #include<fstream> #include<ctime> #include<Windows.h> using namespace std; void GetUserInput(); void PrintWlecome(string UserName); void GetUserInput(); void JusticeUsersChoice(char Choice); void PointReadFile(); void ThroughAll(); void ReviseData(); bool DeletInfo(); void LogWrite(); class Person { private: string name; string id; string numbers; string address; char sex; string age; double salary; string diploma; public: void Set_value(string name1,string id1,string number,string address1,char sex1,double salary1,string age1,string diploma1) { name=name1; id=id1; numbers=number; address=address1; sex=sex1; salary=salary1; diploma=diploma1; age=age1; } friend ofstream &operator<<(ofstream &fout,Person &a) { fout<<a.id<<" "<<a.name<<" "<<a.numbers<<" "<<a.address<<" "<<a.sex<<" "<<a.age<<" "<<a.salary<<" "<<a.diploma<<endl; return fout; } void print() { cout<<id<<"\t"<<name<<"\t"<<numbers<<"\t"<<address<<"\t"<<sex<<"\t"<<age<<"\t"<<salary<<"\t"<<diploma<<endl; } int Write() { ofstream fout("num.dat",ios::app); if(!fout) { cout<<"打开文件num.dat失败"<<endl; } fout<<id<<" "<<name<<" "<<numbers<<" "<<address<<" "<<sex<<" "<<age<<" "<<salary<<" "<<diploma<<endl; fout.close(); return 0; } friend ostream &operator<<(ostream &out,Person &a) { out<<a.id<<" "<<a.name<<" "<<a.numbers<<" "<<a.address<<" "<<a.sex<<" "<<a.age<<" "<<a.salary<<" "<<a.diploma<<endl; return out; } friend ifstream &operator>>(ifstream &fin,Person &people) { fin>>people.id; fin>>people.name; fin>>people.address; fin>>people.sex; fin>>people.age; fin>>people.salary; fin>>people.diploma; return fin; } }; void LogWrite(Person people,string operate) { SYSTEMTIME systime={0}; GetSystemTime(&systime); ofstream fout("log.txt",ios::app); fout<<people<<"\t"<<operate<<" "<<systime.wYear<<":"<<systime.wMonth<<":"<<systime.wDay<<":"<<systime.wHour+8<<":"<<systime.wMinute<<":"<<systime.wSecond<<endl; } void PrintWlecome(string UserName) { system("color 04"); SYSTEMTIME systime={0}; GetSystemTime(&systime); cout<<"尊敬的 "<<UserName<<" 欢迎进入进入本系统!"<<endl; cout<<"系统当前时间:"<<systime.wYear<<":"<<systime.wMonth<<":"<<systime.wDay<<":"<<systime.wHour+8<<":"<<systime.wMinute<<":"<<systime.wSecond<<endl; cout<<"请选择操作\n1.存入信息\n2.删除信息\n3.查找信息\n4.遍历信息\n5.修改信息"<<endl; } void GetUserInput() { string name1; string id1; string number1; string address1; char sex1; string age1; double salary1; string diploma1; Person people; cout<<"请输入\nid 名字 number 地址 性别(m/f) 年龄 薪水 学历(中间有空格)"<<endl; cin>>id1>>name1>>number1>>address1>>sex1>>age1>>salary1>>diploma1; people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1); people.print(); people.Write(); LogWrite(people,"输入"); } void JusticeUsersChoice(char Choice) { if(Choice=='1') { GetUserInput(); } else if(Choice=='2') { DeletInfo(); } else if(Choice=='3') { PointReadFile(); } else if(Choice=='4') { ThroughAll(); } else if(Choice=='5') { ReviseData(); } else{ cout<<"好歹也要选择一个嘛"<<endl; } } void PointReadFile() { bool point=0; char Choice; string FoundName; string Diploma; string name1; string id1; string number1; string address1; char sex1; string age1; double salary1; string diploma1; Person people; ifstream fin("num.dat",ios::in); cout<<"请输入序号\n1.查询id\n2.学历"<<endl; cin>>Choice; if(Choice=='1') { cout<<"请输入id"<<endl; cin>>FoundName; } else { cout<<"请输入学历"<<endl; cin>>Diploma; } if(!fin) { cout<<"打开文件num.dat失败"<<endl; } while(1) { fin>>id1; fin>>name1; fin>>number1; fin>>address1; fin>>sex1; fin>>age1; fin>>salary1; fin>>diploma1; people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1); if(FoundName==id1) { break; } else if(Diploma==diploma1&&!fin.eof()) { cout<<"id 名字 number 地址 性别 年龄 薪水 学历"<<endl; cout<<people; LogWrite(people,"查找"); point=1; } if(fin.eof()) { if(!point) { cout<<"查无此人"<<endl; } break; } } if(FoundName==id1) { cout<<people; LogWrite(people,"查找"); } } bool DeletInfo() { string FoundId; string name1; string id1; string number1; string address1; char sex1; string age1; double salary1; string diploma1; Person people; int point=1; bool HasFound=0; ofstream fout("mid.dat",ios::app); ifstream fin("num.dat",ios::in); cout<<"输入你想查找的id"<<endl; cin>>FoundId; while (point) { fin>>id1; fin>>name1; fin>>number1; fin>>address1; fin>>sex1; fin>>age1; fin>>salary1; fin>>diploma1; people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1); point=!fin.eof(); if(point!=1) { break; } if(FoundId!=id1) { fout<<people; } else { HasFound=1; LogWrite(people,"删除"); } } if(HasFound==0) { cout<<"没有这个职工,请输入正确的职工号"<<endl; } else { point=1; fin.clear(); fin.close(); fout.close(); fout.open("num.dat"); fin.open("mid.dat"); while(point) { fin>>id1; fin>>name1; fin>>number1; fin>>address1; fin>>sex1; fin>>age1; fin>>salary1; fin>>diploma1; people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1); point=!fin.eof(); if(point) { fout<<people; } } fin.clear(); fin.close(); fout.close(); if(remove("mid.dat")) { cout<<"删除中介文件错误"<<endl; } cout<<"删除完成"<<endl; } return 0; } void ReviseData() { string FoundId; string name1; string id1; string number1; string address1; char sex1; string age1; double salary1; string diploma1; Person people; int point=1; bool HasFound=0; ofstream fout("mid.dat",ios::app); ifstream fin("num.dat",ios::in); cout<<"输入你想查找的id"<<endl; cin>>FoundId; while (point) { fin>>id1; fin>>name1; fin>>number1; fin>>address1; fin>>sex1; fin>>age1; fin>>salary1; fin>>diploma1; people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1); point=!fin.eof(); if(point!=1) { break; } if(FoundId!=id1) { fout<<people; } else { HasFound=1; cout<<"请输入id 名字 number 地址 性别(m/f) 年龄 薪水 学历(中间有空格)"<<endl; cin>>id1>>name1>>number1>>address1>>sex1>>age1>>salary1>>diploma1; people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1); fout<<people; LogWrite(people,"修改"); } } if(HasFound==0) { cout<<"没有这个职工,请输入正确的职工号"<<endl; } else { point=1; fin.clear(); fin.close(); fout.close(); fout.open("num.dat"); fin.open("mid.dat"); while(point) { fin>>id1; fin>>name1; fin>>number1; fin>>address1; fin>>sex1; fin>>age1; fin>>salary1; fin>>diploma1; people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1); point=!fin.eof(); if(point) { fout<<people; } } fin.clear(); fin.close(); fout.close(); if(remove("mid.dat")) { cout<<"删除中介文件错误"<<endl; } cout<<"修改完成"<<endl; } } void ThroughAll() { // string name1; // string id1; // string number1; // string address1; // char sex1; // string age1; // double salary1; // string diploma1; ifstream fin("num.dat",ios::in); Person people; int point=1; while(point) { // fin>>id1; // fin>>name1; // fin>>number1; // fin>>address1; // fin>>sex1; // fin>>age1; // fin>>salary1; // fin>>diploma1; fin>>people; point=!fin.eof(); // people.Set_value(name1,id1,number1,address1,sex1,salary1,age1,diploma1); if(point!=1) { break; } cout<<people; } }
2022年06月22日
239 阅读
0 评论
0 点赞
2022-05-21
大数相加
#include<iostream> #include<string> #include<algorithm> using namespace std; int main(){ string a,b,c; int length_a,length_b; cin>>a; cin>>b; length_a=a.length(); length_b=b.length(); reverse(a.begin(),a.end()); reverse(b.begin(),b.end()); if(length_a>=length_b) { for(int i=0;i<(length_a-length_b);i++) { b.append(1,'0'); } } else { for(int i=0;i<(length_b-length_a);i++) { a.append(1,'0'); } } cout<<a<<endl; cout<<b<<endl; if(length_a>=length_b) { for(int i=0;i<length_a;i++) { a[i]-='0'; b[i]-='0'; if((a[i]+b[i])>=10) { c.append(1,(a[i]+b[i])%10); a[i+1]++; c[i]+='0'; } else { c.append(1,a[i]+b[i]); c[i]+='0'; } } } else { for(int i=0;i<length_b;i++) { a[i]-='0'; b[i]-='0'; if((a[i]+b[i])>=10) { c.append(1,(a[i]+b[i])%10); b[i+1]++; c[i]+='0'; } else { c.append(1,a[i]+b[i]); c[i]+='0'; } } } reverse(c.begin(),c.end()); int length_c=c.length(); cout<<c; }
2022年05月21日
220 阅读
0 评论
0 点赞
1
2
3
4
...
8