微信共享位置修改位置共享可以改变自己的位置吗

22:12 提问
c++图书管理系统 有做过的来
文件读写有问题,结构体数据保存时包含了地址,怎么区分开啊?// new2.cpp : 定义控制台应用程序的入口点。
// new.cpp : 定义控制台应用程序的入口点。
#include "stdafx.h"
#include "iostream"
#include "string"
#include "fstream"
#define UNIT_COST 0.1 //每本书每天0.1元
#define MAX_DAY 60 //最长借阅 60天
#define MAX_RENEW 30 //续借30天
#define MAX_RENEW_NUM 1 //续借次数 1
typedef struct BOOK
char sheet_number[10];//编号 名称 类别 作者 出版社 出版时间 价格 数量 备注
char name[10];
char writer[10];
char press[10];
char publication_date[10];
struct BOOK *
struct Password
//struct Password *
}pass={"admin","123456"},*P
Password *c;
typedef struct READER
char card_number[10];//读者证号 姓名 单位
当前借阅数 密码
char name[10];
char unit[10];
int current_
char password[6];
struct READER *
READER *b;
class Log_in
int Administrator_Load();//管理员登陆
int Reader_Load(Reader &b);//读者登陆
int Log();//登陆界面
int Borrow_Book(Booklist &a,Reader &b);//借书
int Return_Book(Booklist &a,Reader &b);//还书
void Search_Book(Booklist &a);//图书查询
void Load_Book(Booklist &a);
void Delete_Book(Booklist &a);
void Manage_load(Reader &b);
void Manage_Delet(Reader &b);
bool Book_State(string sheet_number);//图书状态 借/还
int pay_//缴费
int Log_in::Administrator_Load()
Password *p;
int n=0,f=0;
string na,
while(i!=3)
cout&&"--------------------------------------------------------------------------------"&
if(na!=p-&name||pas!=p-&password)
cout&&"输入错误,重新输入!"&&
system("cls");
cout&&"登录成功!"&&
system("cls");
while(n!=3)
cout&&"--------------------------------------------------------------------------------"&&
1.增添读者
2.删除读者
3.增添图书
4.删除图书
system("cls");
case 1:Manage_load(b); system("cls");
case 2:Manage_Delet(b);system("cls");
case 3:Load_Book(a); system("cls");
case 4:Delete_Book(a);system("cls");
case 5:cout&&" "&&
system("cls");
BOOK *Creat_BOOK()
//初试化图书链表
p=new BOOK;
if(!p) exit(1);
p-&next=NULL;
READER *Creat_READER()
//初试化图书链表
READER *p;
p=new READER;
if(!p) exit(1);
p-&next=NULL;
int Log_in::Reader_Load(Reader &b)
//p=new READER;
ifstream file2("Reader.dat",ios::binary|ios::in);
if(!file2)
cerr&&"file2 error!"&&
int n=0,f=0;
string na,
while(i!=3)
system("cls");
cout&&"--------------------------------------------------------------------------------"&&
按 3 返回上级菜单
while(!file2.eof())
file2.read((char*)&p,sizeof(p));
cout&&p.card_number&&
if(na!=p.card_number&&pas!=p.password)
{cout&&"输入错误,重新输入!"&& system("cls");i++;}
cout&&"登录成功!"&&
system("cls");
while(n!=4)
cout&&"--------------------------------------------------------------------------------"&&
1.查询图书
4.返回上级菜单
case 1:Search_Book(a);cout&& system("cls");
case 2:Borrow_Book(a,b);cout&& system("cls");
case 3:Return_Book(a,b);cout&& system("cls");
system("cls");
file2.close();
int Log_in::Log()
while(n!=9)
cout&&"--------------------------------------------------------------------------------"&
system("cls");
case 1:Administrator_Load();
case 2:Reader_Load(b);
class Info
//Info():BOOK(bok),READER(rea){}
void Load_Book(Booklist &a);
void Delete_Book(Booklist &a);
void Manage_load(Reader &b);
void Manage_Delet(Reader &b);
int Return_Book(Booklist &a,Reader &b);
void Log_in::Search_Book(Booklist &a)
char str[10];
cout&&"input the number: ";
for(;p!=NULL;p=p-&next)
if(strcmp(p-&sheet_number,str)==0)
cout&&"编号 名称 类别 作者 出版社 出版时间 价格 数量 备注"&
coutsheet_number&&" "&name&&" "&sort&&" "&writer&&" "&press&&" "&publication_date&&" "&price&&" "&
void Log_in::Load_Book(Booklist &a)
//借阅时以编号作为主键
p=new BOOK;
//fstream file1;
ofstream file1("book.dat",ios::binary|ios::out);
if(!file1)
cerr&&"file1 error!"&
//p=new BOOK;
//if(!p) exit(1);
if(a!=NULL)
cin&&p-&sheet_
出版社名称:";
出版时间:";
cin&&p-&publication_
p-&note=1;
//1表示没有借出
file1.write((char)&p,sizeof(p));
file1.close();
void Info::load_Book()
cout&&"输入书的 编号 名称 类别 作者 出版社 出版时间 价格 数量 备注"&
cin&&p-&sheet_number&&p-&name&&p-&sort&&p-&writer&&p-&press&&p-&publication_date&&p-&price&&p-&amount&&p-&
cout&sheet_number&&" "&name&&" "&sort&&" "&writer&&" "&press&&" "&publication_date&&" "&price&&" "&amount&&" "&
void Log_in::Delete_Book(Booklist &a)
fstream file1;
file1.open("book.dat",ios::in|ios::out);
if(!file1)
cerr&&"file1 error!"&
char num[10];
while(p-&next!=NULL)
file1.read((char)&p,sizeof(p));
if(p-&sheet_number==num)
file1.write((char*)&p,sizeof(p));
file1.close();
int Log_in::Borrow_Book(Booklist &a,Reader &b)
p=new BOOK;
READER *r;
r=new READER;
fstream file1,file2;
file1.open("book.dat",ios::in|ios::out);
if(!file1)
cerr&&"file1 error!"&
file2.open("Reader.dat",ios::in|ios::out);
if(!file2)
char al[10];
char card[10];
while(p-&next!=NULL)
file1.read((char)&p,sizeof(p));
if((strcmp(p-&sheet_number,al)==0)&&(p-&sort&0))
cout&&"请输入读者证号:"&
while(r-&next!=NULL)
file2.read((char*)&r,sizeof(r));
if((strcmp(r-&card_number,card)==0)&&(r-&current_borrow
p-&sort-=1;
r-&current_borrow+=1;
if(r-&current_borrow&=MAX_DAY)
cout&&"读者已达到最大借阅数!"&
if(strcmp(r-&card_number,card)!=0)
cout&&"读者证号错误!"&
if((p-&sort)==0)
cout&&"本书已全部借出!"&
if(strcmp(p-&sheet_number,al)!=0)
cout&&"对不起本书不存在!"&
file1.write((char*)&p,sizeof(p));
file2.write((char*)&r,sizeof(r));
file1.close();
file2.close();
int Log_in::Return_Book(Booklist &a,Reader &b)
READER *r;
p=new BOOK;
r=new READER;
fstream file1,file2;
file1.open("book.dat",ios::in|ios::out);
if(!file1)
file2.open("Reader.dat",ios::in|ios::out);
if(!file2)
char al[10];
char card[10];
while(p-&next!=NULL)
if(strcmp(p-&sheet_number,al)==0)
cout&&"请输入读者证号:"&
while(r-&next!=NULL)
if(strcmp(r-&card_number,card)==0)
p-&sort+=1;
r-&current_borrow-=1;
if(strcmp(r-&card_number,card)!=0)
cout&&"读者证号错误!"&&
if(strcmp(p-&sheet_number,al)!=0)
cout&&"对不起本书不存在!"&&
file1.write((char*)&p,sizeof(p));
file2.write((char*)&r,sizeof(r));
file1.close();
file2.close();
void Log_in::Manage_load(Reader &b)
//fstream file2;
p=new READER;
fstream file2("Reader.dat",ios::in|ios::out);
if(!file2)
cerr&&"file2 error!"&
if(b-&next==NULL)
读者证号:";
cin&&p-&card_
当前借阅数:";
cin&&p-&current_
file2.write((char)p,sizeof(*p));
file2.close();
Log_in::Manage_Delet(Reader &b)
fstream file2;
file2.open("Reader.dat",ios::in|ios::out);
if(!file2)
cerr&&"file2 error!"&
char card[10];
for(;p!=NULL;p=p-&next)
if(p-&next!=NULL&&(p-&card_number==card))
file2.write((char)&p,sizeof(p));
file2.close();
int _tmain(int argc, _TCHAR* argv[])
fstream file1,file2,file3;
READER *p2;
//Password *p33;
a=Creat_BOOK();
b=Creat_READER();
//c=Creat_Password();
按赞数排序
我曾今写的C语言图书馆管理系统,你可以参考下里面的。其实你的C++版和我这个没多大区别。
你的问题在哪里,还是要源代码...
其他相似问题1140人阅读
C/C++(1)
#include &string&
#include &fstream&
#include &iostream&
const int BMAX = 50;&& //书最多个数
//图书管理模块
class book
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //图书编号
&char name[20];&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //图书名称
&char author[10];&&&&&&&&&&&&&&&&&&&&&&&&&&&& //作者
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //价格
&int b_&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //1为在架,2为借出
&int b_&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //1为存在, 2为删除
&book(){}&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //构造函数
&void setno(int n)
&&no =&&&&&&&&&&&&&&&&&&&&&&&&&&&& //图书编号取值
&int getno()
&&&&&&&&&&&& //返回图书编号值
&void setprice(int p)
&&price =&&&&&&&&&&&&&&&&&&&&&&&&&&&& //图书价格取值
&int getprice()
&&&&&&&&&&&& //返回图书价格值
&void setname(char na[])
&&strcpy(name, na);&& //字符串复制
&char* getname()
&&& //返回图书名称
&void setauthor(char a[])
&&strcpy(author, a);&& //字符串复制
&char* getauthor()
&&& //返回图书作者
&void borbook()
&&b_flag = 2;&&&& //借书标志
&void delbook()
&&b_del = 2;&& //删除标志
&void addbook(int no, char na[], char author[], int price)&&& //增加图书功能
&&setno(no);
&&setname(na);
&&setauthor(author);
&&setprice(price);
&&b_flag = 1;
&&b_del = 1;
//图书数据库类
class bdatabase
&book btarray[BMAX];&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //图书集合
&bdatabase()
&&top = -1;
&&fstream file(&book.txt&, ios::in);&&& //打开文件
&&while (1)
&&&file.read((char *)&b, sizeof(b));
&&&if (!file)
&&&top++;
&&&btarray[top] =
&&file.close(); &&& //关闭文件
&~bdatabase()&&&&&&&&&&&&&&&&&&&&& //析构函数,&&& 将btarray[]写到book.txt文件中
&&fstream file(&book.txt&, ios::out);
&&for (int i = 0; i &= i++)
&&&if (btarray[i].b_del == 1)
&&&&file.write((char *)&btarray[i], sizeof(btarray[i]));
&&file.close();
&void addbooks()&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //往图书数据库中加图书
&&char bname[20];
&&char bau[10];
&&cout && endl && &请输入书号: &;
&&cout && endl && &请输入书名: &;
&&cout && endl && &请输入作者: &;
&&cout && endl && &请输入价格: &;
&&bk.b_flag = 1;
&&bk.addbook(no, bname, bau, pr);
&&top++;
&&btarray[top] =
&int findbooks(int suffix)&&&&&&& //查找图书,这个函数用于借书这书操作,suffix是数组下标
&&cout && &请输入书号: &;
&&for (int i = 0; i &= i++)
&&&if (btarray[i].no == no && btarray[i].b_del == 1)
&&return -1;
&int findbooks()&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //查找图书,这个函数用于图书维护&
&&char value[6];
&&cout && &请输入书号: &;
&&for (int i = 0; i &= i++)
&&&if (btarray[i].no == no && btarray[i].b_del == 1)
&&&&if (btarray[i].b_flag == 1) strcpy(value, &在架&);
&&&&if (btarray[i].b_flag == 2) strcpy(value, &借出&);
&&&&cout && &书号: & && btarray[i].no && & 书名: & && btarray[i].name && & 作者: & && btarray[i].author && & 价格: & && btarray[i].price && & 图书状态 :& && value &&
&&return -1;
&void editbooks()&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //编辑图书
&&cur = findbooks();
&&if (cur == -1)
&&&cout && &没有这本书& &&
&&cout && &书号: & && btarray[cur].no && & 书名: & && btarray[cur].name && & 作者: & && btarray[cur].author && & 价格: & && btarray[cur].price &&
&&cout && &请修改数据:& &&
&&cout && endl && &书的名称: &;
&&cin && btarray[cur].
&void delbooks()&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //删除图书
&&cur = findbooks();
&&if (cur == -1)
&&if (btarray[cur].b_flag == 2)&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //删除时判断图书是否借出
&&&cout && &该图书已经借出,请在归还后再删除。& &&
&&btarray[cur].b_del = 2;
&void listbooks()&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //显示全部图书
&&char value[6];
&&for (int i = 0; i &= i++)
&&&if (btarray[i].b_del == 1)
&&&&if (btarray[i].b_flag == 1) strcpy(value, &在架&);
&&&&if (btarray[i].b_flag == 2) strcpy(value, &借出&);
&&&&cout && &书号: & && btarray[i].no && & 书的名称: & && btarray[i].name && & 图书状态 :& && value &&
//读者管理模块
class reader
&&&&& //读者性别,1表示男,0表示女
&char name[20];
&int r_& //1存在,2删除
&int r_& //1借过书,2没有借书
&void addreader(int id, char na[], int s)//增加读者
&&strcpy(name, na);
&&r_del = 1;
&void setbrbook(book bt)& //设置借书标记
&&brbook =
&book getbrbook()
&&&& //返回借书信息
//读者数据库类
class rdatabase
&reader rdarray[BMAX];
&rdatabase()
&&top = -1;
&&fstream file(&reader.txt&, ios::in); //打开文件
&&while (1)
&&&file.read((char *)&rd, sizeof(rd));
&&&if (!file)
&&&top++;
&&&rdarray[top] =
&&file.close(); &//关闭文件&&
&~rdatabase()//析构函数
&&fstream file(&reader.txt&, ios::out);
&&for (int i = 0; i &= i++)
&&&if (rdarray[i].r_del == 1)
&&&&file.write((char *)&rdarray[i], sizeof(rdarray[i]));
&&file.close();
&void addreaders()&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //添加读者
&&char rname[20];
&&cout && &请输入学号: &;
&&cout && endl && &请输入姓名: &;
&&cout && endl && &请输入性别(1为男,0为女):&;
&&rd.addreader(no, rname, rs);
&&rd.r_bor = 2;
&&top++;
&&rdarray[top] =
&int findreaders(int suffix)&&&& //查找读者,这个函数用于借书还书操作。 参数suffix是数组下标
&&cout && &请输入学号: &;
&&for (int i = 0; i &= i++)
&&&if (rdarray[i].no == no && rdarray[i].r_del == 1)
&&return -1;
&int findreaders()&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //查找读者,这个函数用于读者维护操作
&&char value[3];
&&cout && &请输入学号: &;
&&for (int i = 0; i &= i++)
&&&if (rdarray[i].no == no && rdarray[i].r_del == 1)
&&&&if (rdarray[i].r_bor == 1) strcpy(value, &借&);
&&&&if (rdarray[i].r_bor == 2) strcpy(value, &无&);
&&&&cout && &学号: & && rdarray[i].no && & 姓名: & && rdarray[i].name && & 是否借书: & && value &&
&&return -1;
&void editreaders()&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //编辑读者信息
&&cur = findreaders();
&&if (cur == -1)
&&&cout && &没有该学生& &&
&&cout && &请修改数据:& &&
&&cout && endl && & 姓名: &;
&&cin && rdarray[cur].
&void delreaders()&&&&&&&&&&&&&&&&&&&&&&&&&&& //删除读者,读者如果借书要还书后才能删除
&&cur = findreaders();
&&if (cur == -1)
&&if (rdarray[cur].r_bor == 1)
&&&cout && &该用户借了图书,请还书后再删除& &&
&&rdarray[cur].r_del = 2;
&void listreaders()&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //显示所有读者
&&char value[3];
&&for (int i = 0; i &= i++)
&&&if (rdarray[i].r_del == 1)
&&&&if (rdarray[i].r_bor == 1) strcpy(value, &借&);
&&&&if (rdarray[i].r_bor == 2) strcpy(value, &无&);
&&&&cout && &学号: & && rdarray[i].no && & 姓名: & && rdarray[i].name && & 是否借书: & && value &&
void bookjiemain()&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //图书维护子菜单
&cout && &****************************& &&
&cout && &*&&&&&&&& 图书维护&&&&&&&& *& &&
&cout && &*&&&&&&& (1)增 加&&&&&&&&& *& &&
&cout && &*&&&&&&& (2)更 改&&&&&&&&& *& &&
&cout && &*&&&&&&& (3)删 除&&&&&&&&& *& &&
&cout && &*&&&&&&& (4)查 找&&&&&&&&& *& &&
&cout && &*&&&&&&& (5)显 示&&&&&&&&& *& &&
&cout && &*&&&&&&& (6)返回上一层&&&& *& &&
&cout && &****************************& &&
void readerjiemian()&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //读者维护子菜单
&cout && &****************************& &&
&cout && &*&&&&&&&& 读者维护&&&&&&&& *& &&
&cout && &*&&&&&&& (1)增 加&&&&&&&&& *& &&
&cout && &*&&&&&&& (2)更 改&&&&&&&&& *& &&
&cout && &*&&&&&&& (3)删 除&&&&&&&&& *& &&
&cout && &*&&&&&&& (4)查 找&&&&&&&&& *& &&
&cout && &*&&&&&&& (5)显 示&&&&&&&&& *& &&
&cout && &*&&&&&&& (6)返回上一层&&&& *& &&
&cout && &****************************& &&
void mainjiemian()&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //主界面
&cout && &***********************************************& &&
&cout && &*&&&&&&&&&&&&&& 图 书 管 理 系 统&&&&&&&&&&&& *& &&
&cout && &*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *& &&
&cout && &*&&&&&&&&&&&&&& (1) 借 书&&&&&&&&&&&&&&&&&&&& *& &&
&cout && &*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *& &&
&cout && &*&&&&&&&&&&&&&& (2) 还 书&&&&&&&&&&&&&&&&&&&& *& &&
&cout && &*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *& &&
&cout && &*&&&&&&&&&&&&&& (3) 图 书 管 理&&&&&&&&&&&&&& *& &&
&cout && &*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *& &&
&cout && &*&&&&&&&&&&&&&& (4) 用 户 管 理&&&&&&&&&&&&&& *& &&
&cout && &*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *& &&
&cout && &*&&&&&&&&&&&&&& (0) 退 出&&&&&&&&&&&&&&&&&&&& *& &&
&cout && &***********************************************& &&
void borrowtoreturn(char br)
//借书还书函数.参数br用来判断是“借书”还是“还书”.1为“借书”,2为“还书”
&int rdid = 0;
&int bkid = 0;
&int rsuffix,
&bdatabase t_
&rdatabase t_
&if (br == '1')&&&&&&&&&& //借书
&&rsuffix = t_rd.findreaders(rdid);
&&bsuffix = t_bd.findbooks(bkid);
&&if (rsuffix == -1 || bsuffix == -1)
&&if (t_bd.btarray[bsuffix].b_flag == 2)
&&&cout && &图书已经借出,请选择其它图书& &&
&&if (t_rd.rdarray[rsuffix].r_bor == 1)
&&&cout && &你已经借过图书,请先归还再借其它图书& &&
&&t_bd.btarray[bsuffix].b_flag = 2;
&&t_rd.rdarray[rsuffix].r_bor = 1;
&&t_rd.rdarray[rsuffix].brbook = t_bd.btarray[bsuffix];
&if (br == '2')
&&rsuffix = t_rd.findreaders(rdid);
&&bsuffix = t_bd.findbooks(bkid);
&&if (rsuffix == -1 || bsuffix == -1)
&&if (t_rd.rdarray[rsuffix].brbook.no == t_bd.btarray[bsuffix].no)
&&&t_bd.btarray[bsuffix].b_flag = 1;
&&&t_rd.rdarray[rsuffix].r_bor = 2;
&&&t_rd.rdarray[rsuffix].brbook = t_bd.btarray[bsuffix];
&&&cout && &请重新输入,读者借的图书号不正确& &&
void booksmange()
&bdatabase&
&&bookjiemain();
&&switch (in)
&&case '1':
&&&bd.addbooks();
&&case '2':
&&&bd.editbooks();
&&case '3':
&&&bd.delbooks();
&&case '4':
&&&bd.findbooks();
&&case '5':
&&&bd.listbooks();
&&case '6':
&&default:cout && &输入错误,请从新输入。& &&;
&} while (in != '6');
void readersmange()
&rdatabase&
&&readerjiemian();
&&switch (in)
&&case '1':
&&&bd.addreaders();
&&case '2':
&&&bd.editreaders();
&&case '3':
&&&bd.delreaders();
&&case '4':
&&&bd.findreaders();
&&case '5':
&&&bd.listreaders();
&&case '6':
&&default:cout && &输入错误,请从新输入。& &&
&} while (in != '6');
int main(int argc, char* argv[])
&&mainjiemian();
&&switch (in)
&&case '1':
&&&borrowtoreturn(in);
&&case '2':
&&&borrowtoreturn(in);
&&case '3':
&&&booksmange();
&&case '4':
&&&readersmange();
&&case '0':
&&default:cout && &输入错误,请从新输入。& &&
&} while (in != '0');
&return 0;
&&相关文章推荐
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:1453次
排名:千里之外c常用算法即源码(3)
&&相关文章推荐
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:8643次
排名:千里之外
(2)(2)(4)(3)}

我要回帖

更多关于 微信共享实时位置伪装 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信