下↓

发布时间 2023-12-01 20:09:47作者: 王ys
#include<iostream>
#include <fstream>
using namespace std;
struct card{
    string name;
    int id;
    int money;
    bool build_card(int x_id,string x_name){
        name=x_name;
        id=x_id;
        return true;
    }
    bool chong(int x_money){
        money+=x_money;
        return true;
    }
    bool hua(int x_money){
        if(money>=x_money&&x_money>0){
            money-=x_money;
            return true;
        }
        return false;
    }
};
int main(){
    card cardlist[100];
    int firstid=1000;
    int number=0;
    int now_money;
    string data;
    ifstream file;
    file.open("1.txt");
    	while(getline(file,data)){		
		if(data.length()>5){
			
			cout<<data<<endl;
		} 
		//eof 是否到了文件末尾 
		if(file.eof()){
			cout<<"end"<<endl;
			break;		
		}
	}	
	file.close();
	/*
    while(1){
        cout<<"*饭卡管理系统*"<<endl<<"1.办卡"<<"2.充值"<<"3.消费"<<"4.查询余额"<<endl;
        int index;
        cin>>index;
        card c;
        bool have=false;
        switch(index){
            case 1:            
                cout<<"请输入姓名:";
                cin>>c.name;
                c.id=firstid+number;
                cardlist[number]=c;
                cout<<"办卡成功"<<cardlist[number].name<<",你的卡号:"<<cardlist[number].id<<endl;
                number++;
                break;
        	case 2:
                cout<<"请输入你的卡号:";
                int _cid;
                cin>>_cid;
                for(int i=0;i<=number;i++){
                    if(cardlist[i].id==_cid){
                        cout<<cardlist[i].name<<"同学你好,请输入充值金额:";
                        cin>>c.money;
                        cardlist[number]=c;
                        cout<<"充值成功,目前金额:"<<cardlist[number].money<<endl;
                        have=true;
                        break;
                    }
                }
                if(have==false){
                    cout<<"对不起,没有查询到该卡号"<<endl;
                }
                break;
            case 3:
                cout<<"请输入你的卡号:";
                cin>>_cid;
                have=false;
                for(int i=0;i<=number;i++){
                    if(cardlist[i].id==_cid){
                        cout<<cardlist[i].name<<"同学你好,请输入花费金额:";
                        cin>>c.money;
                        cardlist[number]=c;
                        cout<<"花费成功,目前金额:"<<cardlist[number].money<<endl;
                        have=true;
                        break;
                    }
                }
                if(have==false){
                    cout<<"对不起,没有查询到该卡号"<<endl;
                }
                break;
            case 4:
                cout<<"请输入你的卡号:";
                cin>>_cid;
                have=false;
                for(int i=0;i<=number;i++){
                    if(cardlist[i].id==_cid){
                        cout<<cardlist[i].name<<"同学你好目前余额:"<<cardlist[number].money<<endl;
                        have=true;
                        break;
                    }
                }
                if(have==false){
                    cout<<"对不起,没有查询到该卡号"<<endl;
                }
                break;
        }
    }
    */
    return 0;
}