首页
关于
Search
1
python初学示例
550 阅读
2
欢迎使用 Typecho
512 阅读
3
晒谷子
493 阅读
4
痛
475 阅读
5
蓝桥杯2022年第十三届省赛真题-X进制减法
465 阅读
默认分类
登录
Search
Typecho
累计撰写
35
篇文章
累计收到
10
条评论
首页
栏目
默认分类
页面
关于
搜索到
35
篇与
默认分类
的结果
2023-01-27
腾讯云开发者平台入驻
腾讯云开发者平台入驻我的博客即将同步至腾讯云开发者社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan?invite_code=5e986vqayuap
2023年01月27日
126 阅读
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日
219 阅读
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日
236 阅读
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日
212 阅读
0 评论
0 点赞
2022-05-21
线性表
2.设计一个程序,生成两个按值非递减有序排列的线性表LA和LB,再将LA和LB归并为一个新的线性表LC,且LC中的数据仍按值非递减有序排列,输出线性表LA、LB、LC。#include<iostream> using namespace std; struct node { int data; node *next; }; class linklist { private: int length_a; node *first; public: linklist(){ first=new node; first->next=NULL; } linklist(int a[],int len_a); void display();//输出函数 void appendd(int num);//在单链表尾部添加数据 ~linklist(){} friend linklist through(linklist &a,linklist &b);//友元函数,访问两个类,并且将加得的单链表,作为一个类返回; }; linklist::linklist(int a[],int len_a) { first=new node; node *p=first; for(int i=0;i<len_a;i++) { node *s=new node; s->data=a[i]; p->next=s; p=s; } p->next=NULL; } void linklist::appendd(int num){ node *p=first; while(p->next!=NULL) { p=p->next; } node *s=new node; s->data=num; p->next=s; p=s; p->next=NULL; } linklist through(linklist &a,linklist &b) { linklist m; node *p1=a.first->next; node *p2=b.first->next; while(p1!=NULL || p2!=NULL) { if(p1!=NULL && p2!=NULL) { if((p1->data)<=(p2->data)) { m.appendd(p1->data); m.appendd(p2->data); } else { m.appendd(p2->data); m.appendd(p1->data); } p1=p1->next; p2=p2->next; } else if(p1==NULL && p2!=NULL) { m.appendd(p2->data); p2=p2->next; } else { m.appendd(p1->data); p1=p1->next; } } return m; } void linklist::display() { node *p=first->next; while(p!=NULL) { cout<<p->data<<endl; p=p->next; } } int main() { int a[3]={1,3,5},b[5]={2,4,6,7,9}; linklist link_a(a,3),link_b(b,5),link_c; link_c=through(link_a,link_b); link_c.display(); system("pause"); }代码还是有一点有问题的,只能按一对一的大小排序,要真正实现升序,需要对链表进行排序
2022年05月21日
200 阅读
0 评论
0 点赞
1
2
3
4
...
7