#include <iostream>using namespace std; namespace MySpace {//定义命名空间typedef struct account {int num;//账号double balance; //账户余额}Account;}; /*////////////////////////////学生代码开始////////////////////////////////////////////// ////////////////////////////学生代码结束///////////////////////////////////////////// int main() {int flag;MySpace::Account A[20] = { { 20120001,100.1 },{ 20130001,2000.3 },{ 20140001,1500 },{ 20140002,50 } };int a = 8, b = 9, c;double sum;c = ADD(a, b);//实现两个整数相加int select;cin >> select;switch (select) {case 1:cout << "OK" << endl;break;case 2:sum = ADD(A[2], A[3]);//返回两个账户的余额总数cout << int(sum) << endl;break;case 3:sum = ADD(A, 4);//返回前n(当前值为4)个账户的余额总数cout << int(sum) << endl;break;case 4:sum = ADD(A);//缺省账户个数为2,即实现前两个账户余额相加cout << int(sum) << endl;break;case 5:double amount;cin >> amount;flag = Bank_Transfer(A[1], A[2], amount);//从账户A[2]中转出amount,存入账户A[1]中if (flag == 1)cout << int(A[1].balance) << " " << int(A[2].balance) << endl;elsecout << "余额不够" << endl;break;case 6:flag = Bank_Transfer(A[1], A[2]);//从账户A[2]中转出50(默认值),存入账户A[1]中if (flag == 1)cout << int(A[1].balance) << " " << int(A[2].balance) << endl;elsecout << "余额不够" << endl;break; }return 0;}
1 回答
- 1 回答
- 0 关注
- 1364 浏览
添加回答
举报
0/150
提交
取消