精通
英语
和
开源
,
擅长
开发
与
培训
,
胸怀四海
第一信赖
#include "iostream.h" #include <stdio.h> #include <stdlib.h> struct ACCOUNT_STRU {int num; char name[10]; float c_in[5]; float q_out[5]; float money; }; static int count=3; static int m=0; static int n=0; //一个函数一个函数写,不要一下写一堆函数出来,写一个函数,编译下,联调下,在功力强时才一下写多个,你这代码研究下,重新建立工程写吧 //代码要对齐,才好理解,对齐按alt+f8 //初始化结构体 // struct ACCOUNT_STRU people [3]={{1,"张三",0.0,0.0,78.0},{2,"李四",0.0,0.0,89.0},{3,"王五",0.0,0.0,95.0}}; struct ACCOUNT_STRU people[3]={{1,"张三",0.0,0.0,78.0},{2,"李四",0.0,0.0,89.0},{3,"王五",0.0,0.0,95.0}};//最后一个分号错了 //建立链表 struct ACCOUNT_STRU * p,*head,*tail; // p=struct ACCOUNT_STRU people; // p=people;//语句要写到函数里,这里根本没函数啊 // head=p; // for (i=0,i<2,i++) // {p->next=p+1; // p=p+1; // } // tail=p; // tail->next=NULL; main () { int a; int b=0; while(b>=0) { cout<<"请选择操作事项:";//这里又用了中文的分号 cin>>a; // if (a=0)//判断要用==,不能用= if (a==0) { cout<<"退出程序"; break; } else //else要和if语句紧随,或if语句带的{}代码块紧随 // /*while (a<0||a>4) // {cout<<"请输入正确操作选项";//循环里条件不满足,要再输入条件,如象下面写的哪样 // }*/ if(a<0 || a>4) { cout<<"请输入正确操作选项"; continue; } switch (int a) { //error C2065: 'kaihu' : undeclared identifier,要在前面声明函数 case 1:kaihu(); break; case 2: xiaohu(); break; case 3: chun(); break; case 4: qu(); break; case 5: yuer(); break; case 6: zhuanzhang(); break; case 7: chaxun(); break; case 8: tuichu(); break; } b++; } } // 定义个ACCOUNT_STRU数组来表示银行。注释一定要带标志 // 写个函数来表示ATM的功能的模拟: //创建一个节点 //kaihu' : illegal use of type 'void',函数定义要带() void kaihu() { struct ACCOUNT_STRU *p1; //开户 //error C2133: 'name' : unknown size 数组定义要具体的长度 char name[]; int mum; //error C2065: 'malloc' : undeclared identifier,这需要包含头文件 p1=(struct ACCOUNT_STRU)malloc(sizeof(struct ACCOUNT_STRU)); tail->next=p1; tail=p1; tail->next=null; cout<<"请输入姓名和账号:"; cin>>name>>num; //可以直接是 cin>>p1->name >>p1->num? count++; return 0; } xiaohu{ //销户 struct ACCOUNT_STRU *p1; p1=head; int mum; int flag=0; cout<<"请输入要注销的账户:"; cin>>num; while (flag==0) {for (i=0;i<count;i++)//寻找要操作的节点 { if (p1->num=num) {free(p1); flag=1; break;} else (p1=p1->next; ) } if (p1=null) {cout<<"没有该账户,请重新输入:" } cin>>num; } }; chun{ struct ACCOUNT_STRU *p1;//存钱 p1=head; int mum; int flag=0; float money; cout<<"请输入要操作的账户:"; cin>>num; while (flag==0) {for (i=0;i<count;i++) { if (p1->num=num) {cout<<"请输入要存入的金额:"; cin>>money; p1->c_in[n]=money; n++ p1->money=p1->money+p1->c_in; flag=1; break;} else (p1=p1->next; ) } if (p1=null) {cout<<"没有该账户,请重新输入:" } cin>>num; } } qu { struct ACCOUNT_STRU *p1;//取钱 p1=head; int mum; int flag=0; float money; cout<<"请输入要操作的账户:"; cin>>num; while (flag==0) {for (i=0;i<count;i++) { if (p1->num=num) {cout<<"请输入要取的金额:"; cin>>money; if (p1->q_out[m]>=money;) {cout<<"账上余额不足"; cin>>money; } } p1->money=p1->money-p1->q_out[m]; flag=1; break;} else (p1=p1->next; ) } if (p1=null) {cout<<"没有该账户,请重新输入:" } cin>>num; } yuer{struct ACCOUNT_STRU *p1;//余额 p1=head; int mum; int flag=0; float money; cout<<"请输入要查询的账户:"; cin>>num; while (flag==0) {for (i=0;i<count;i++) { if (p1->num=num) {cout<< p1->money; flag=1; break;} else (p1=p1->next; ) } if (p1=null) {cout<<"没有该账户,请重新输入:" } cin>>num; } } //zhuanzhang //error C2373: 'zhuanzhang' : redefinition; different type modifiers,重复定义了 zhuanzhang()//函数定义要带() { //error C2018: unknown character '0xaa',用了中文的空格了 struct ACCOUNT_STRU *p1; p1=head; int mum1; int num2; int flag=0; float money; //error C2146: syntax error : missing ';' before identifier 'cin'一行结束要带;分号 cout<<"请输入要转入的账户:"; cin>>num1; cout<<"请输入要转入的金额:"; cin>> money; cout<<"请输入要转出的账户:"; cin>>num2; while (flag==0) //error C2065: 'i' : undeclared identifier,变量要定义后再使用 {for (int i=0;i<count;i++)//寻找要操作的节点 { //{和if要分开成2行 if (p1->num=num2) { if (p1->money<money) { cout<<"余额不足"; cin>>money } p1->money=p1->money-money; flag=1; break; } else //error C2143: syntax error : missing ')' before ';',代码块是用{},不是用(),如果代码块里只有一行,可以省略{} p1=p1->next; } if (p1=null) {cout<<"没有该账户,请重新输入:";//一行结束要带; } cin>>num2; while (flag==0) {for (i=0;i<count;i++)//寻找要操作的节点 { if (p1->num=num1) {p1->money=p1->money+money; flag=1; break;} else (p1=p1->next; ) } if (p1=null) {cout<<"没有该账户,请重新输入:" } cin>>num1;} } } tuichu{ cout<<"退出操作" }; chaxun{struct ACCOUNT_STRU *p1;//查询 p1=head; int mum; int flag=0; float money; cout<<"请输入要查询的账户:"; cin>>num; while (flag==0) {for (i=0;i<count;i++) { if (p1->num=num) {for (i=0;i<5;i++) {cout<<"存入"<<p1->c_in[i]; cout<<"取出"<<p1->q_out[i]; } flag=1; break;} else (p1=p1->next; ) } if (p1=null) {cout<<"没有该账户,请重新输入:" } cin>>num; } }