标题:求改错~淘宝拍卖仿真系统
只看楼主
deargod007
该用户已被删除
已结贴  问题点数:30 回复次数:7 
求改错~淘宝拍卖仿真系统
提示: 作者被禁止或删除 内容自动屏蔽
搜索更多相关主题的帖子: 淘宝 拍卖 系统 改错 仿真 
2010-10-13 19:13
deargod007
该用户已被删除
得分:0 
提示: 作者被禁止或删除 内容自动屏蔽
2010-10-13 19:18
hahayezhe
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:湖南张家界
等 级:贵宾
威 望:24
帖 子:1386
专家分:6999
注 册:2010-3-8
得分:7 
string fname2=no "_p.txt";
string fname=x.id "_c.txt";
string fname=z "_c.txt";
什么意思?


2010-10-13 20:38
deargod007
该用户已被删除
得分:0 
回复 3楼 hahayezhe
提示: 作者被禁止或删除 内容自动屏蔽
2010-10-13 20:58
chenyang5200
Rank: 1
等 级:新手上路
帖 子:2
专家分:7
注 册:2010-10-16
得分:7 
新人路过。。话说我学C#
2010-10-16 01:50
无情云
Rank: 1
等 级:新手上路
帖 子:22
专家分:7
注 册:2010-9-25
得分:7 
不好意思哦,我有几处地方不知道你为什么这样写哦...
string fname2=no "_p.txt";
fname=p[t].pno "_p.txt";
fname=s "_p.txt";
outfile<<a 1<<" "<<newpr.pname<<'\n';
oufile<<a 1;//这里你是不是要定义a1的变量啊
stamp=now 864000;//这里的那个now又是什么意思呢?
string fname=x.id "_c.txt";
string fname=z "_c.txt";
string fname=log.id "_c.txt";
fname1=x.id "_c.txt";
怎么都是一样的啊,你是不是少写了什么啊,直接看不通哦。
2010-10-16 20:44
无情云
Rank: 1
等 级:新手上路
帖 子:22
专家分:7
注 册:2010-9-25
得分:0 
#include<iostream>
#include<fstream>
#include<ctime>
#include<cstdlib>
#include<iomanip>
#include<string>

#define space "\t\t\t"
using namespace std;
class customer{
      public:
             string id;
             string password;
             string phone,mail;
      };
            
class Product{
      public:
             string pname;
             double price;
             string deadline;
             string pno,other;
};

void a_price(string z,string y,double x);
void newproduct(string z);
void list(string z);   
void regist(customer x);
void login();
void menu(string z);
void information(string z);
void modify(customer x);
void store();
int i=0;
customer c;

void index(){
    ifstream infile;
    infile.open("number.ini");
    infile>>i;
    int choice;   
    cout<<space<<"****欢迎使用在线仿真拍卖系统****\n"<<space<<"\t(已注册人数:"<<i<<")"<<endl;
    cout<<"\t\t\t   制作人:XXX  \n"<<endl;
    cout << "\t\t1 -- 注册\t2 -- 登录\t3--退出\n";
    cin>>choice;
    switch(choice){
                   case 1: regist(c);
                   case 2: login();
                   case 3: exit(0);
    }
}
void store(){
    i=i-1;
    ofstream outfile;
    outfile.open("number.ini");
    outfile<<i;
    outfile.close();
}
void regist(customer x){
         cout<<"\n请输入用户名(不得超过12个字符):\n";
         cin>>x.id;
         while((x.id).length()>12){
                 cout<<"!!!用户名过长,请重新输入...\n";
                 cout<<"\n请输入用户名(不得超过12个字符):\n";
                 cin>>x.id;               
                 }
         cout<<"检查用户名是否可用"<<endl;
         system("PAUSE");
         ifstream infile;
         string fname1;
         fname1=x.id ;//"_c.txt";
         infile.open(fname1.c_str(),ios::in);
         string same_n;
         infile>>same_n;
         if(same_n!=x.id){
                     cout<<"\n ^_^ 恭喜!该用户名可用。"<<endl;
                     }
         else{
         cout<<"\n T_T 对不起,该用户名已存在\n\n请重新输入..." <<endl;
         regist(x);
         }
          cout<<"\n请输入密码(不得超过20位):\n" ;
          cin>>x.password;
         while((x.password).length()>20){
                 cout<<"!!!密码过长,请重新输入...\n";
                 cout<<"\n请输入密码(不得超过20位):\n" ;
                 cin>>x.password;               
                 }
         system("pause");
         system("cls");
         cout<<"请输入联系电话:\n";
         cin>>x.phone;
         cout<<"请输入电子邮箱:\n";
         cin>>x.mail;
         string fname2;
         fname2=x.id ;//"_c.txt";
         ofstream file(fname2.c_str());
         file<<x.id<<'\n'<<x.password<<'\n'<<x.phone<<'\n'<<x.mail;
         file.close();
         cout<<"信息保存成功!!"<<endl;
         store();
         system("PAUSE");
         system("cls");
         index();        
}
void login(){
     customer log;
     customer a;
     cout<<"请输入用户名:";
     cin>>log.id;
     cout<<"请输入密码:";
     cin>>log.password;
     ifstream infile;
     string fname=log.id ;//"_c.txt";
     infile.open(fname.c_str());
     infile>>a.id>>a.password;
                     if(log.id==a.id&&log.password==a.password)
                     {
                         system("cls");
                         menu(a.id);//转到产品列表等菜单
                         }
                         else{
     system("cls");
     cerr<<"用户名或密码错误,是否重新输入(Y/N)\n";
     char c;
     cin>>c;
     if(c=='Y'||c=='y')
     login();
     else index();
                             }
}
void menu(string z){
     cout<<"\n\n\t\t......&欢迎"<<z<<"进入拍卖系统&......\n"
     <<space<<"$1. 用户信息\n"
     <<space<<"$2. 自出产品参与竞拍\n"
     <<space<<"$3. 在线竞拍产品信息列表\n"
     <<space<<"$4. 退出系统\n";
     int c;
     cin>>c;
     switch(c){
               case 1: information(z);// 竞拍计时器
               case 2: newproduct(z);
               case 3: list(z);
               case 4: system("cls");index();
              }
}
   
void information(string z){   
     ifstream infile;
     string fname=z ;//"_c.txt";
     infile.open(fname.c_str());
     customer a;
     infile>>a.id>>a.password>>a.phone>>a.mail;
     cout<<"\n用户名:"<<a.id<<"\n联系电话:"<<a.phone<<"\n电子邮箱:"<<a.mail;
     cout<<"\n......您的信息如上.......\n"<<"\n#1.修改密码"<<space<<"#2.返回\n";
     int c;
     cin>>c;
     switch(c){
               case 1: modify(a);
               case 2: system("cls");menu(a.id);
               }
     system("PAUSE");
}

void modify(customer x){
         cout<<"请输入新密码:\n" ;
         cin>>x.password;
         system("cls");
     ofstream outfile;
     string fname=x.id ;//"_c.txt";
     outfile.open(fname.c_str());
         outfile<<x.id<<'\n'
             <<x.password<<'\n'
             <<x.phone<<'\n'
             <<x.mail;
         outfile.close();
         cout<<"密码修改成功!!"<<endl;
         system("PAUSE");
         index();        
}

string set(){
                  string c;
                  time_t stamp;
                  time_t now=time(0);
                  stamp=864000;//now 864000;
                  c=ctime( &stamp);
                  return c;}
           
void a_price(string z,string y,double x){
     string set();
     ifstream infile;
     ofstream outfile;
     infile.open(y.c_str(),ios::in);
     Product p;
     string day1,mon1,da1,t1,y1,name1;
     infile>>p.pname>>p.price>>day1>>mon1>>da1>>t1>>y1>>name1>>p.other;
     if(x>p.price)
     {
      p.deadline=set();
      p.price=x;
      outfile.open(y.c_str());
      outfile<<p.pname<<'\n'<<p.price<<'\n'<<p.deadline<<'\n'<<z<<'\n'<<p.other;
      outfile.close();
      cout<<"\n**恭喜竞价成功!**\n"<<endl;
      cout<<"~~返回产品列表~~";
      system("PAUSE");
      system("cls");
      list(z);
      }
     else{
     cerr<<"\n对不起,您的出价无效!\n";
     cout<<"\n1.重新输入竞价  ||   2.返回主菜单\n";
     int c;
     cin>>c;
     switch(c){
               case 1: {double newpric;cout<<"\n重新输入的价格:";cin>>newpric;a_price(z,y,newpric);}
               case 2: system("cls");menu(z);   
   
              }
          }
     infile.close();
   
}
  
void newproduct(string z){
     string set();
     Product newpr;
     cout<<"请输入产品名称:";
     cin>>newpr.pname;
     ifstream infile;
     ifstream ifile;
     ofstream outfile;
     ofstream oufile;
     infile.open("product.ini");
     int a=0;
     infile>>a;
     oufile.open("product.ini");
     oufile<<a;
     oufile.close();
     outfile.open("list.txt",ios::app);
     outfile<<a<<" "<<newpr.pname<<'\n';
     outfile.close();
     ifile.open("product.ini");
     string s;
     ifile>>s;
     string fname;
     fname=s ;//"_p.txt";
     ofstream file(fname.c_str());  
     cout<<"请输入底价:";
     cin>>newpr.price;
     newpr.deadline=set();
     cout<<"产品简介:\n";
     cin>>newpr.other;
     file<<newpr.pname<<'\n'
         <<newpr.price<<'\n'
         <<newpr.deadline<<'\n'
         <<z<<'\n'<<newpr.other;
     file.close();
     system("PAUSE");
     system("cls");
     menu(z);
     }
void list(string z){
     cout<<setw(4)<<"产品编号 "<<setw(10)<<"产品名称\t"<<setw(10)<<"目前最高价\t"<<"拍卖截止日期"<<"\t\t\t出价者"<<endl;
     Product p[1000];
     int scope;
     ifstream infile,ifile;
     infile.open("product.ini",ios::in);
     infile>>scope;
     ifile.open("list.txt");
     for(int t=0;t<=scope;t )
     {
     ifile>>p[t].pno>>p[t].pname;
     if(t<scope){
     string fname;
     fname=p[t].pno ;//"_p.txt";           
     ifstream in_file;
     in_file.open(fname.c_str());           
     Product d;
     d.pno=p[t].pno;
     string day,mon,da,t,y,name;
     in_file>>d.pname>>d.price>>day>>mon>>da>>t>>y>>name;
     cout<<setw(4)<<d.pno<<'\t'<<setw(10)<<d.pname<<'\t'<<setw(10)<<d.price<<'\t'<<day<<" "<<mon<<" "<<da<<" "<<t<<" "<<y<<'\t' <<name<<endl;
     }
     else
     break;
     }
     cout<<"---------------------------------\n"
         <<"  1.查看商品详细信息\t"<<"2.返回主菜单\n";
         int c;
         cin>>c;
         if(c==1)
         {
         string no;
         cout<<"请输入产品编号:\n";
         cin>>no;
         string fname2=no ;//"_p.txt";
         ifstream pfile;
         pfile.open(fname2.c_str());
         Product pd;
         string day1,mon1,da1,t1,y1,name1;
         pfile>>pd.pname>>pd.price>>day1>>mon1>>da1>>t1>>y1>>name1>>pd.other;
         cout<<"\n产品详细信息如下>>\n";
         cout<<"\n产品名称: "<<pd.pname<<endl;
         cout<<"目前最高价: "<<pd.price<<" 元"<<endl;
         cout<<"截止日期: "<<day1<<" "<<mon1<<" "<<da1<<" "<<t1<<" "<<y1<<endl;
         cout<<"最高价出价者: "<<name1<<endl;
         cout<<"产品简介:\n"<<pd.other<<endl;
         cout<<"\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"
             <<"1.我要出价||2.返回列表\n"<<endl;
             int ch;
             cin>>ch;
             if(ch==1){
                       cout<<"您出的价格为: ";
                       double newprice;
                       cin>>newprice;
                       a_price(z,fname2,newprice);
            
             }
             else list(z);
         }
         else {system("cls");menu(z);}
}

int main()
{
    index();
    return EXIT_SUCCESS;
}
--------------------Configuration: taobao - Win32 Debug--------------------
Compiling...
taobao.cpp
Linking...

taobao.exe - 0 error(s), 0 warning(s)

不好意思,这是我改过几处地方,你看看吧。希望你能找到更好的方法。
2010-10-16 20:52
机默吾同
Rank: 1
来 自:36
等 级:新手上路
帖 子:2
专家分:7
注 册:2010-10-14
得分:7 
有些字符串的地方的加号漏了,变成了“ ”
2010-10-16 22:40



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-322798-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035498 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved