【救命一命】帮我把这c++代码改写成c代码,课程设计弄错了!

骨头教主 2015-07-14 06:08:24
后天就要答辩,自己改来不及了,很少50块辛苦费,但还是希望大家帮帮我。我生活费不多了,另外求求版主手下留情。帮帮我这个无知少年,好心第一个帮我改出来的最后请附上支付宝。下面是c++的代码,功能是一个简单的餐厅点餐系统,对餐单进行增加修改删除,客户点餐最后结账,代码如下
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
using namespace std;
/*
菜单食物的类
*/

class Food
{
private:
string name;//菜名
string kind;//分类
int price;//价格
public:
friend class Dish;
Food(){}
Food(string n,string k,int p )
{
name = n;
price = p;
kind=k;
}

void setName(string n)
{
name = n;
}
string getName()
{
return name;
}
void setKind(string k)
{
kind = k;
}
string getKind()
{
return kind;
}
int getPrice()
{
return price;
}
void setPrice(int p)
{
price = p;
}
string numberToString (int x )
{
string result;
stringstream convert;
convert << x;
result = convert.str();
return result;
}
};
Food foods[100];
int FoodsOfnumbr =0;
/*
在磁盘文件对菜单的读写
*/
class Dish
{
public :
friend class Food;
//字符串转为数字
int stringToInt(string s)
{
int thevalue;
istringstream ss(s);
ss >> thevalue;
return thevalue;
}
//字符串分割函数
void split(string s, string fields[] )
{
istringstream ss( s );
int f = 0;
while (ss)
{
string s;
if (!getline( ss, s, '\t' )) break;
fields[f] = s;
f++;
}
}
/*
读取磁盘文件里面的菜单信息
*/
bool readFood()
{
ifstream myDish;
myDish.open("d://food.txt");//打开D盘根目录的food.txt
string line;
string members[3];
int p = 0;;
int highestId = 0;
if (myDish.is_open())
{
while ( ! myDish.eof() )
{
getline (myDish,line);
if(line.length() > 0)
{ // avoid empty lines
split(line, members);
foods[p] = Food(members[0],members[2],stringToInt(members[1]));
p++;
}
}

FoodsOfnumbr = p;
myDish.close();
return true;
}
else
{
ofstream out;
out.open("d://food.txt");//若是还没有任何菜单信息则创建一个food.txt文件

return false;

}
}
/*
吧菜单信息写入磁盘文件
*/
bool writeFood()
{
ofstream myDish;
myDish.open("d://food.txt");//打开D盘根目录的food.txt
if (myDish.is_open())
{
for (int i = 0; i < FoodsOfnumbr; i++){
myDish << foods[i].getName() + "\t" + foods[i].numberToString(foods[i].getPrice()) + "\t" +foods[i].getKind() <<"\n";

}
myDish.close();
return true;
} else return false;
}
/*
输出菜单
*/
void printFoods()
{
if(FoodsOfnumbr==0){cout<<"暂时还没有任何菜式"<<endl;return ;
}
cout << "菜单如下:" << endl;
cout << "菜单号\t菜名\t价格\t分类\n" ;
for (int i = 0; i < FoodsOfnumbr; i++)
{
cout << i << "\t" << foods[i].getName() + "\t" + foods[i].numberToString(foods[i].getPrice()) + "\t" + foods[i].getKind()<< endl;

}
}
/*
修改菜式
*/
void changeFood(int p)
{
if(p<0||p>=FoodsOfnumbr)
{
cout << "没有菜单号为" <<p<<"的菜\n";return;
}
int action;
cout << "当前菜式的信息:\n" ;
cout << "编号\t菜名\t价格\t分类\n" ;
cout<< p << "\t" << foods[p].getName() + "\t" + foods[p].numberToString(foods[p].getPrice()) + "\t" +foods[p].getKind()<< endl;
cout<< "请选择:"<<endl;
cout<<"1.修改菜名"<<endl;
cout<<"2.修改价格"<<endl;
cout<<"3.修改分类"<<endl;

cin >> action ;
string name;
string kind;
int price;
switch(action)
{
case 1:cout << "请输入新菜名 :" ;

cin >>name ;
foods[p].setName(name);break;
case 2:cout << "请输入它的价格 :" ;
cin >>price ;
foods[p].setPrice(price);break;
case 3:cout << "请输入它的分类 :" ;
cin >>kind ;
foods[p].setKind(kind);break;

default:cout<<"输入错误\n"<<endl;
}
}
/*
删除菜式
*/
void deleteFood(int p)
{
if(p<0||p>=FoodsOfnumbr)
{
cout << "没有菜单号为" <<p<<"的菜\n";return;
}
for (int i = p; i < FoodsOfnumbr; i++)
{
foods[i] = foods[i+1];
}
FoodsOfnumbr--;
cout << "删除成功!\n";
}
/*
增加菜式
*/
void addFood()
{
string n = "";
string k = "";
int p;
bool word;
cout << "输入新的菜式的信息: " << endl;
do
{
cout << "菜名 : ";
cin >> n;
word = false ;
for(int i=0;i<FoodsOfnumbr;i++)
if(n == foods[i].getName()) {word = true;cout << "已经有" <<n<<"这个菜了!请重新输入!\n";break;}
}
while(word);
cout << "价格 :";
cin >> p;
cout << "分类 :";
cin >> k;
foods[FoodsOfnumbr] = Food(n,k,p);
FoodsOfnumbr++;
}
};
class Mangement
{
public:
void showDish()
{
int action = 0;
int pos = 0;
Dish d;
do
{
d.printFoods();
cout<<"\n"<<endl;
cout<< "1.修改菜单"<<endl;
cout<<"2.删除菜式"<<endl;
cout<<"3.添加菜式"<<endl;
cout << "4.退出"<<endl;
cin >> action;
switch (action)
{
case 1:
cout <<"输入要修改的菜 :";
cin >> pos ;
d.changeFood(pos);
break;
case 2:
cout <<"输入要删除的菜 :";
cin >> pos ;
d.deleteFood(pos);
break;
case 3:
d.addFood();
break;
case 4: return;
default:
cout << "非法操作!";
}

}
while (1);


}

};

class client
{
private : int money;
int rpMoney;
int b[100];
int number;

public :
client()
{
number=0;
money=0;
}
void add()
{
int p ;
cout << "请出入你想点的菜单号:";
cin >> p ;
for(int i=0;i<number;i++)
if(p==b[i])
{
cout << "您已经点过这个菜了!\n" ;
return ;
}
b[number++] = p ;

money+=foods[p].getPrice();

}

void deletefood()
{
int p ;
int i;
if(money == 0) {cout<<"您还没有点菜\n";
return;
}
for(i=0;i<number;i++)
{
cout << b[i] <<"\t"<< foods[b[i]].getName() + "\t" + foods[b[i]].numberToString(foods[b[i]].getPrice())<<endl;
}
cout << "共" << money << "元\n" ;
cout << "请出入你想撤销的菜单号:";
cin >> p ;

for( i=0;i<=number;i++)
{
if(b[i] == p) { b[i] = b[number--] ; money-=foods[p].getPrice();

}
}
if(i>number) cout<<"没有点这个菜\n";
}

void show()
{
int i;
if(money==0) return ;
cout << "您已点:" <<endl;
for(i=0;i<number;i++)
{
cout << foods[b[i]].getName() + "\t" + foods[b[i]].numberToString(foods[b[i]].getPrice())<<"元"<<endl;
}
cout << "共" << money << "元\n" ;
}

void showclient()
{
int pos;
Dish d;
d.printFoods();
cout<<"\n"<<endl;
do
{

cout<<"请选择:"<<endl;
cout<<"1.点菜"<<endl;
cout<<"2.取消"<<endl;
cout<<"3.结账"<<endl;
cout<<"4.退出"<<endl;
cin >> pos ;
switch(pos)
{

case 1: add();break;
case 2: deletefood();break;
case 3: cout << "你共消费了" << money << "元钱。\n欢迎您下次光临!\n"; return ;
case 4 : return ;
default:
cout << "非法操作!\n";
}
show();
}
while(1);
}

};

int main()
{
Dish dish;
client c;
Mangement mangement;
int i;
dish.readFood();

while(1)
{
cout << " ***************************欢迎使用点餐管理系统!****************************" <<endl;
cout << "------------------------------1.用户点餐-------------------------------------"<<endl;
cout << "------------------------------2.菜单管理-------------------------------------"<<endl;
cout << "------------------------------3.退出-----------------------------------------"<<endl;
cin >> i;
switch(i)
{
case 1:c.showclient();break;
case 2:mangement.showDish();break;
case 3:dish.writeFood();system("pause");return 0;
default: cout<<"输入错误,请重新选择!"<<endl;break;
}

}
return 0;
}
...全文
155 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
假正经的班长 2015-07-14
  • 打赏
  • 举报
回复
骨头教主 2015-07-14
  • 打赏
  • 举报
回复
引用 7 楼 cjqpker 的回复:

#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>

/*
菜单食物的类
*/
typedef struct _food
{
    char name[128];//菜名
    char kind[128];//分类
    int price;//价格
}Food;

void setName(Food* f, const char* n) 
{
    assert(f && n);
    strcpy(f->name, n);
}	
const char* getName(Food* f) 
{
    assert(f);
    return f->name;
}
void setKind(Food* f, const char*  k) 
{
    assert(f && k);
    strcpy(f->kind, k);
}	
const char* getKind(Food* f) 
{
    assert(f);
    return f->kind;
}
int getPrice(Food* f) 
{
    assert(f);
    return f->price;
}
void setPrice(Food* f, int p) 
{    
    f->price = p;
}
const char* numberToString (int x, char* buf)
{
    return _itoa(x, buf, 10);
}

Food foods[100];
int FoodsOfnumbr =0;

/*
读取磁盘文件里面的菜单信息
*/
int readFood()
{
    int i;
    FILE* p = fopen("d://food.txt", "r");
    if (!p)
    {
        return 0;
    }

    for (i = 0; !feof(p); i++)
    {
        fscanf(p, "%s\t%d\t%s\n", &foods[i].name, &foods[i].price, &foods[i].kind);
        FoodsOfnumbr++;
    }
    fclose(p);

    return 1;
}

/*
把菜单信息写入磁盘文件
*/
int writeFood()
{
    int i;
    FILE* p = fopen("d://food.txt", "w+");

    if (p)
    {
        for (i = 0; i < FoodsOfnumbr; i++)
        {
            fprintf(p, "%s\t%d\t%s\n", foods[i].name, foods[i].price, foods[i].kind);
        }
        fclose(p);
        return 1;
    }
    else
    {
        return 0;
    }
}

/*
输出菜单
*/
void printFoods()
{
    int i;
    if(FoodsOfnumbr==0)
    {
        printf("暂时还没有任何菜式\n");
        return ;
    }
    printf("菜单如下:\n");
    printf("菜单号\t菜名\t价格\t分类\n");
    for (i = 0; i < FoodsOfnumbr; i++)
    {
        printf("%d\t%s\t%d\t%s\n", i, foods[i].name,  foods[i].price,  foods[i].kind); 
    }
}

/*
修改菜式
*/
void changeFood(int p)
{
    int action;
    char name[128] = {0};
    char kind[128] = {0};
    int price;

    if(p < 0 || p >= FoodsOfnumbr) 
    {
        printf("没有菜单号为%d的菜\n", p);
        return;
    }
    printf("当前菜式的信息:\n") ;
    printf("编号\t菜名\t价格\t分类\n");
    printf("%d\t%s\t%d\t%s\t", p, foods[p].name, foods[p].price, foods[p].kind);
    printf("请选择:\n");  
    printf("1.修改菜名\n");  
    printf("2.修改价格\n");  
    printf("3.修改分类\n");  

    scanf("%d", &action);
    switch(action)
    {
    case 1:printf("请输入新菜名 :");
        scanf("%s", name);
        setName(&foods[p], name); break;

    case 2:printf("请输入它的价格 :");
        scanf("%d", &price);
        setPrice(&foods[p], price); break;

    case 3:printf("请输入它的分类 :");
        scanf("%s", kind);
        setKind(&foods[p], kind); break;

    default:printf("输入错误\n");
    }
}

/*
删除菜式
*/
void deleteFood(int p)
{
    int i;
    if( p < 0 || p >= FoodsOfnumbr) 
    {
        printf("没有菜单号为%d的菜\n", p);
        return;
    }
    for (i = p; i < FoodsOfnumbr; i++)
    {
        foods[i] = foods[i+1];
    }
    FoodsOfnumbr--;
    printf("删除成功!\n");
}
/*
增加菜式
*/
void addFood()
{
    int i;
    char n[128] = {0};
    char k[128] = {0};
    int p;
    int word;

    printf("输入新的菜式的信息: \n");
    do
    {
        printf("菜名 : ");
        scanf("%s", n);
        word = 0 ;
        for(i = 0 ; i < FoodsOfnumbr; i++) 
        {
            if(strcmp(n, foods[i].name) == 0) 
            {
                word = 1;
                printf("已经有%s这个菜了!请重新输入!\n", n);
                break;
            }
        }
    }while(word);

    printf("价格 :");
    scanf("%d", &p);
    printf("分类 :");
    scanf("%s", k);
    setName(&foods[FoodsOfnumbr], n);
    setKind(&foods[FoodsOfnumbr], k);
    setPrice(&foods[FoodsOfnumbr], p);
    FoodsOfnumbr++;
}


void showDish()
{
    int action = 0;
    int pos = 0;

    do 
    {
        printFoods();
        printf("\n\n");
        printf( "1.修改菜单\n");
        printf("2.删除菜式\n");
        printf("3.添加菜式\n");
        printf("4.退出\n");
        scanf("%d", &action);
        switch (action) 
        {
        case 1:
            printf("输入要修改的菜 :");
            scanf("%d", &pos);
            changeFood(pos);
            break;
        case 2:
            printf("输入要删除的菜 :");
            scanf("%d", &pos);
            deleteFood(pos);
            break;
        case 3:
            addFood();
            break;
        case 4:	return;	
        default:
            printf("非法操作!");
        }	

    } 
    while (1);


}

typedef struct _client
{
    int money;
    int rpMoney;
    int b[100];
    int number;
}client;

void resetclient(client* c)
{
    c->money = 0;
    c->number = 0;
    c->rpMoney = 0;
    memset(c->b, 0, sizeof(c->b));
}

void add(client* c)
{
    int i;
    int p ;

    printf("请出入你想点的菜单号:");
    scanf("%d", &p);

    if (p > FoodsOfnumbr - 1)
    {
        printf("没有这个菜\n");
        return;
    }

    for(i=0; i < c->number; i++)
    {
        if(p==c->b[i]) 
        {
            printf("您已经点过这个菜了!\n");
            return ;
        }
    }

    c->b[c->number++] = p ;
    c->money += foods[p].price; 
}

void deletefood(client* c)
{
    int p ;
    int i;
    if(c->money == 0) 
    {
        printf("您还没有点菜\n");
        return;
    }
    for(i = 0; i < c->number; i++)
    {
        printf("%d\t%s\t%d\n", c->b[i], foods[c->b[i]].name, foods[c->b[i]].price);
    }	   
    printf("共 %d 元\n", c->money);
    printf("请出入你想撤销的菜单号:");
    scanf("%d", &p);

    for( i = 0; i <= c->number; i++)
    {
        if(c->b[i] == p) 
        { 
            c->b[i] = c->b[c->number--] ;
            c->money -= foods[p].price; 
        }
    }
    if(i > c->number) printf("没有点这个菜\n");
}

void show(client* c)
{
    int i;
    if(c->money == 0) return ;
    printf("您已点:\n");
    for(i=0; i < c->number; i++)
    {
        printf("%s\t%d元\n", foods[c->b[i]].name, foods[c->b[i]].price);
    }	   
    printf("共 %d 元\n", c->money);
}

void showclient(client* c)
{
    int pos;
    printFoods();
    printf("\n\n");
    do
    {
        printf("请选择:\n"); 
        printf("1.点菜\n");      
        printf("2.取消\n");       
        printf("3.结账\n"); 
        printf("4.退出\n");   
        scanf("%d", &pos);
        switch(pos)
        {

        case 1:  add(c);break;
        case 2:  deletefood(c);break;
        case 3:  printf("你共消费了 %d 元钱。\n欢迎您下次光临!\n", c->money); return ;
        case 4 : return ;
        default:
            printf("非法操作!\n");
        }
        show(c);
    }
    while(1);
}


int main()
{
    client c;
    int i;

    resetclient(&c);
    memset(foods, 0, sizeof(foods));
    readFood();

    while(1)
    {
        printf(" ***************************欢迎使用点餐管理系统!****************************\n");
        printf("------------------------------1.用户点餐-------------------------------------\n");        
        printf("------------------------------2.菜单管理-------------------------------------\n"); 
        printf("------------------------------3.退出-----------------------------------------\n"); 
        scanf("%d", &i);
        switch(i)
        {
        case 1:showclient(&c);break;
        case 2:showDish();break;
        case 3:writeFood();system("pause");return 0;
        default: printf("输入错误,请重新选择!\n");break;
        }

    }
    return 0;
}
你自己的测试一下,有啥错的地方自己改改就好
谢谢您了!辛苦了!太感谢了!
假正经的班长 2015-07-14
  • 打赏
  • 举报
回复

#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>

/*
菜单食物的类
*/
typedef struct _food
{
    char name[128];//菜名
    char kind[128];//分类
    int price;//价格
}Food;

void setName(Food* f, const char* n) 
{
    assert(f && n);
    strcpy(f->name, n);
}	
const char* getName(Food* f) 
{
    assert(f);
    return f->name;
}
void setKind(Food* f, const char*  k) 
{
    assert(f && k);
    strcpy(f->kind, k);
}	
const char* getKind(Food* f) 
{
    assert(f);
    return f->kind;
}
int getPrice(Food* f) 
{
    assert(f);
    return f->price;
}
void setPrice(Food* f, int p) 
{    
    f->price = p;
}
const char* numberToString (int x, char* buf)
{
    return _itoa(x, buf, 10);
}

Food foods[100];
int FoodsOfnumbr =0;

/*
读取磁盘文件里面的菜单信息
*/
int readFood()
{
    int i;
    FILE* p = fopen("d://food.txt", "r");
    if (!p)
    {
        return 0;
    }

    for (i = 0; !feof(p); i++)
    {
        fscanf(p, "%s\t%d\t%s\n", &foods[i].name, &foods[i].price, &foods[i].kind);
        FoodsOfnumbr++;
    }
    fclose(p);

    return 1;
}

/*
把菜单信息写入磁盘文件
*/
int writeFood()
{
    int i;
    FILE* p = fopen("d://food.txt", "w+");

    if (p)
    {
        for (i = 0; i < FoodsOfnumbr; i++)
        {
            fprintf(p, "%s\t%d\t%s\n", foods[i].name, foods[i].price, foods[i].kind);
        }
        fclose(p);
        return 1;
    }
    else
    {
        return 0;
    }
}

/*
输出菜单
*/
void printFoods()
{
    int i;
    if(FoodsOfnumbr==0)
    {
        printf("暂时还没有任何菜式\n");
        return ;
    }
    printf("菜单如下:\n");
    printf("菜单号\t菜名\t价格\t分类\n");
    for (i = 0; i < FoodsOfnumbr; i++)
    {
        printf("%d\t%s\t%d\t%s\n", i, foods[i].name,  foods[i].price,  foods[i].kind); 
    }
}

/*
修改菜式
*/
void changeFood(int p)
{
    int action;
    char name[128] = {0};
    char kind[128] = {0};
    int price;

    if(p < 0 || p >= FoodsOfnumbr) 
    {
        printf("没有菜单号为%d的菜\n", p);
        return;
    }
    printf("当前菜式的信息:\n") ;
    printf("编号\t菜名\t价格\t分类\n");
    printf("%d\t%s\t%d\t%s\t", p, foods[p].name, foods[p].price, foods[p].kind);
    printf("请选择:\n");  
    printf("1.修改菜名\n");  
    printf("2.修改价格\n");  
    printf("3.修改分类\n");  

    scanf("%d", &action);
    switch(action)
    {
    case 1:printf("请输入新菜名 :");
        scanf("%s", name);
        setName(&foods[p], name); break;

    case 2:printf("请输入它的价格 :");
        scanf("%d", &price);
        setPrice(&foods[p], price); break;

    case 3:printf("请输入它的分类 :");
        scanf("%s", kind);
        setKind(&foods[p], kind); break;

    default:printf("输入错误\n");
    }
}

/*
删除菜式
*/
void deleteFood(int p)
{
    int i;
    if( p < 0 || p >= FoodsOfnumbr) 
    {
        printf("没有菜单号为%d的菜\n", p);
        return;
    }
    for (i = p; i < FoodsOfnumbr; i++)
    {
        foods[i] = foods[i+1];
    }
    FoodsOfnumbr--;
    printf("删除成功!\n");
}
/*
增加菜式
*/
void addFood()
{
    int i;
    char n[128] = {0};
    char k[128] = {0};
    int p;
    int word;

    printf("输入新的菜式的信息: \n");
    do
    {
        printf("菜名 : ");
        scanf("%s", n);
        word = 0 ;
        for(i = 0 ; i < FoodsOfnumbr; i++) 
        {
            if(strcmp(n, foods[i].name) == 0) 
            {
                word = 1;
                printf("已经有%s这个菜了!请重新输入!\n", n);
                break;
            }
        }
    }while(word);

    printf("价格 :");
    scanf("%d", &p);
    printf("分类 :");
    scanf("%s", k);
    setName(&foods[FoodsOfnumbr], n);
    setKind(&foods[FoodsOfnumbr], k);
    setPrice(&foods[FoodsOfnumbr], p);
    FoodsOfnumbr++;
}


void showDish()
{
    int action = 0;
    int pos = 0;

    do 
    {
        printFoods();
        printf("\n\n");
        printf( "1.修改菜单\n");
        printf("2.删除菜式\n");
        printf("3.添加菜式\n");
        printf("4.退出\n");
        scanf("%d", &action);
        switch (action) 
        {
        case 1:
            printf("输入要修改的菜 :");
            scanf("%d", &pos);
            changeFood(pos);
            break;
        case 2:
            printf("输入要删除的菜 :");
            scanf("%d", &pos);
            deleteFood(pos);
            break;
        case 3:
            addFood();
            break;
        case 4:	return;	
        default:
            printf("非法操作!");
        }	

    } 
    while (1);


}

typedef struct _client
{
    int money;
    int rpMoney;
    int b[100];
    int number;
}client;

void resetclient(client* c)
{
    c->money = 0;
    c->number = 0;
    c->rpMoney = 0;
    memset(c->b, 0, sizeof(c->b));
}

void add(client* c)
{
    int i;
    int p ;

    printf("请出入你想点的菜单号:");
    scanf("%d", &p);

    if (p > FoodsOfnumbr - 1)
    {
        printf("没有这个菜\n");
        return;
    }

    for(i=0; i < c->number; i++)
    {
        if(p==c->b[i]) 
        {
            printf("您已经点过这个菜了!\n");
            return ;
        }
    }

    c->b[c->number++] = p ;
    c->money += foods[p].price; 
}

void deletefood(client* c)
{
    int p ;
    int i;
    if(c->money == 0) 
    {
        printf("您还没有点菜\n");
        return;
    }
    for(i = 0; i < c->number; i++)
    {
        printf("%d\t%s\t%d\n", c->b[i], foods[c->b[i]].name, foods[c->b[i]].price);
    }	   
    printf("共 %d 元\n", c->money);
    printf("请出入你想撤销的菜单号:");
    scanf("%d", &p);

    for( i = 0; i <= c->number; i++)
    {
        if(c->b[i] == p) 
        { 
            c->b[i] = c->b[c->number--] ;
            c->money -= foods[p].price; 
        }
    }
    if(i > c->number) printf("没有点这个菜\n");
}

void show(client* c)
{
    int i;
    if(c->money == 0) return ;
    printf("您已点:\n");
    for(i=0; i < c->number; i++)
    {
        printf("%s\t%d元\n", foods[c->b[i]].name, foods[c->b[i]].price);
    }	   
    printf("共 %d 元\n", c->money);
}

void showclient(client* c)
{
    int pos;
    printFoods();
    printf("\n\n");
    do
    {
        printf("请选择:\n"); 
        printf("1.点菜\n");      
        printf("2.取消\n");       
        printf("3.结账\n"); 
        printf("4.退出\n");   
        scanf("%d", &pos);
        switch(pos)
        {

        case 1:  add(c);break;
        case 2:  deletefood(c);break;
        case 3:  printf("你共消费了 %d 元钱。\n欢迎您下次光临!\n", c->money); return ;
        case 4 : return ;
        default:
            printf("非法操作!\n");
        }
        show(c);
    }
    while(1);
}


int main()
{
    client c;
    int i;

    resetclient(&c);
    memset(foods, 0, sizeof(foods));
    readFood();

    while(1)
    {
        printf(" ***************************欢迎使用点餐管理系统!****************************\n");
        printf("------------------------------1.用户点餐-------------------------------------\n");        
        printf("------------------------------2.菜单管理-------------------------------------\n"); 
        printf("------------------------------3.退出-----------------------------------------\n"); 
        scanf("%d", &i);
        switch(i)
        {
        case 1:showclient(&c);break;
        case 2:showDish();break;
        case 3:writeFood();system("pause");return 0;
        default: printf("输入错误,请重新选择!\n");break;
        }

    }
    return 0;
}
你自己的测试一下,有啥错的地方自己改改就好
骨头教主 2015-07-14
  • 打赏
  • 举报
回复
引用 5 楼 西伯利亚冰的回复:
引用 4 楼 zhuyucheng11 的回复:
[quote=引用 1 楼 cjqpker 的回复:] 你把你的 “d://food.txt” 贴上来一份
那是个空文件,用来保存录入的信息的
好的,我知道了,一会写好贴在这里。[/quote] 真是谢谢您能抽空帮我了!
假正经的班长 2015-07-14
  • 打赏
  • 举报
回复
引用 4 楼 zhuyucheng11 的回复:
引用 1 楼 cjqpker 的回复:
你把你的 “d://food.txt” 贴上来一份
那是个空文件,用来保存录入的信息的
好的,我知道了,一会写好贴在这里。
骨头教主 2015-07-14
  • 打赏
  • 举报
回复
引用 1 楼 cjqpker 的回复:
你把你的 “d://food.txt” 贴上来一份
那是个空文件,用来保存录入的信息的
骨头教主 2015-07-14
  • 打赏
  • 举报
回复
food.txt,是组建后自动生成的空文件啊,用来保存菜的信息的
假正经的班长 2015-07-14
  • 打赏
  • 举报
回复
帮你改改,不要钱。
假正经的班长 2015-07-14
  • 打赏
  • 举报
回复
你把你的 “d://food.txt” 贴上来一份

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧