蒙其D可乐 蒙其D可乐
关注数: 0 粉丝数: 44 发帖数: 933 关注贴吧数: 4
菜鸟求教!!为什么账户和余额是乱码?? #include<iostream> #include<fstream> #include<string> #include<iomanip> #include<stdio.h> #include<stdlib.h> #include<time.h> using namespace std; #define OK 1 #define ERROR 0 #define OVERFLOW -2 typedef int Status;//Status 是函数返回值类型,其值是函数结果状态代码。 typedef int ElemType;//ElemType 为可定义的数据类型,此设为int类型 typedef struct account{ char ID[8];//账号 char Name[10];//账户名字 float balance;//账户余额//指向第一个存取记录结点的指针 }account; #define MAXSIZE 1000 typedef struct { account *elem; int length; }SqList; Status InitList_Sq(SqList &L){//构造一个空的账户表L L.elem=new account[MAXSIZE];//为顺序表分配一个大小为MAXSIZE的数组空间 if(!L.elem) exit(OVERFLOW); //存储分配失败退出 L.length=0;//空表长度为0 return OK; } Status ListInsert_Sq(SqList&L,account e){//创建新账户 if(L.length==MAXSIZE) return ERROR; int num; num=2018000+L.length; L.elem[L.length]=e; itoa(num,e.ID,10); e.balance=0; ++L.length; return OK; } int main(){ SqList L; account e; int choose,temp; if(InitList_Sq(L)) cout<<"成功建立账户表!\n"; cout<<" 活期储蓄管理系统菜单 \n"; cout<<"==============================\n"; cout<<"= 1 创建新账户 =\n"; cout<<"= 2 销户 =\n"; cout<<"= 3 存款 =\n"; cout<<"= 4 取款 =\n"; cout<<"= 5 显示所有账户信息 =\n"; cout<<"= 6 余额查询 =\n"; cout<<"= 7 交易记录查询 =\n"; cout<<"= 0 退出 =\n"; cout<<"==============================\n\n"; choose=-1; while(choose!=0){ cout<<"请选择:"; cin>>choose; switch(choose){ case 1: temp=ListInsert_Sq(L,e); if(temp!=0){ cout<<"请输入姓名:"; cin>>e.Name; cout<<"账户创建成功,账号为:"<<e.ID<<endl<<endl; cout<<"余额为:"<<e.balance<<endl<<endl; } else cout<<"账户创建失败!\n"; break; } } return 0; } 上面是代码
1 下一页