C语言实现ATM

一级目录包括:开户,登录(本程序由于技术问题,需要在电脑D盘下添加一个     “00ATMv2.00”    文件夹,   在此文件夹下添加一个      “ATMv2.00”     记事本

二级目录包括:取款,存款,查询,改密,销户,转账

本程序可以容纳三个账户,由于水平较低所以请按照规范操作,先开户再登录。

请看代码

#include
#include
#include
#include
#include
#include
#include  // 包含输入输出函数的头文件
using namespace std;
#define s 3

/*

	文件储存格式,框内数字表示位置
 +-----------------------------------+
 |    |   a       b       c       d  |//每行第一个数字顶行写,无空格
 |-----------------------------------|//每一行的后两位数字前各有十个空格
 |  1 |   0       11      22      33 |//最后一个数字之后只有九个空格,最后一位是换行符
 |  2 |   46      57      68      79 |
 |  3 |   92      103     114     125|//first first1合并使用可以实现十位数的覆盖输入
 +-----------------------------------+//first first2合并使用可以实现十位数的局部输出

*/

void denglu();
void kaihu();
void sanfang();
void cunqian(int k);
void quqian(int k);
void xiugai(int k);
void chaxun(int k);
void xiaohu(int k);
void menu2(int k);
void menu();
void kuahang(int k);
void zhuanzhang(int k);

/*   
D:\\00ATMv2.00\\ATMv2.00.txt
*/

FILE* ide = NULL;//文件指针 
int i;
struct
{
	int ID[3];
	int Password[3];
	int Money[3];
	int z[3];
} RENA[3], *pa;

void menu()//登录或者开户页面
{
	
	int cho, a;
	printf("\n\n                  *************************************************\n                                    *简易ATM*\n\n\n                 *1.登录                                 *2.开户\n\n");
	printf("                 *3.初始化(刷新数据或首次)             *4.退出\n\n\n                  *************************************************\n\n");
	printf("                                  请选择服务项目\n                                        ");
	scanf_s("%d", &a);
	switch (a)
	{
	case 1:system("cls");
		denglu();
		break;
	case 2:system("cls");
		kaihu();
		break;
	case 3:system("cls");
		sanfang();
		break;
	case 4:system("cls");
		exit(0);
		break;
	default:system("cls"); menu(); break;
	}
}
void denglu()//登录
{
	while (1)
	{
		int a, b, c, d;
		pa = RENA;
		fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r");
		fseek(ide, 11, SEEK_SET);
		fscanf_s(ide, "%d", &a);
		fseek(ide, 57, SEEK_SET);
		fscanf_s(ide, "%d", &b);
		fseek(ide, 103, SEEK_SET);
		fscanf_s(ide, "%d", &c);
		printf("请输入您的账号。\n");
		scanf_s("%d", &d);
		if (d == a)
		{
			fseek(ide, 22, SEEK_SET);
			fscanf_s(ide, "%d", &a);
			printf("请输入您的密码。\n");
			scanf_s("%d", &d);
			if (d == a)
			{
				i = 1;
				fclose(ide);
				system("cls");
				printf("操作成功,请稍后。\n");
				Sleep(5000);
				system("cls");
				menu2(i);
			}
			else {
				system("cls");
				continue;
			}
		}
		if (d == b)
		{
			fseek(ide, 68, SEEK_SET);
			fscanf_s(ide, "%d", &a);
			printf("请输入您的密码。\n");
			scanf_s("%d", &d);
			if (d == a)
			{
				fclose(ide);
				system("cls");
				i = 2;
				printf("操作成功,请稍后。\n");
				Sleep(5000);
				system("cls");
				menu2(i);
			}
			else {
				system("cls");
				continue;
			}
		}
		if (d == c)
		{
			fseek(ide, 114, SEEK_SET);
			fscanf_s(ide, "%d", &a);
			printf("请输入您的密码。\n");
			scanf_s("%d", &d);
			if (d == a)
			{
				fclose(ide);
				system("cls");
				i = 3;
				printf("操作成功,请稍后。\n");
				Sleep(5000);
				system("cls");
				menu2(i);
			}
			else {
				system("cls");
				continue;
			}
		}
		else
		{
			printf("如果还没有账号请按1,输入错误请按2.\n");
			scanf_s("%d", &a);
			if (a == 1)
			{
				fclose(ide);
				printf("暂时还没有账号,请先开户。\n");
				printf("即将自动返回主页面。\n");
				Sleep(5000);
				system("cls");
				menu();
			}
			else
			{
				system("cls");
				continue;
			}	
		}	
	}
}
void kaihu()//开户
{
		int a;
		pa = RENA;
		fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r+");//建立账号
		fseek(ide, 11, SEEK_SET);
		fscanf_s(ide, "%d", &a);
		if (a == 0)
		{
			fseek(ide, 11, SEEK_SET);
			printf("请设置账号(100000--999999)\n");
			scanf_s("%d", &pa->ID[i]);		
			fprintf(ide, "%d", pa->ID[i]);
			fseek(ide, 22, SEEK_SET);
			printf("设置密码(100000--999999)\n");
			scanf_s("%d", &pa->Password[i]);
			fprintf(ide, "%d", pa->Password[i]);
			fclose(ide);
			system("cls");
			menu();
		}
		if (a != 0)
		{
			fseek(ide, 57, SEEK_SET);
			fscanf_s(ide, "%d", &a);
			if (a == 0)
			{
				fseek(ide, 57, SEEK_SET);
				printf("请设置账号(100000--999999)\n");
				scanf_s("%d", &pa->ID[i]);
				fprintf(ide, "%d", pa->ID[i]);
				fclose(ide);
				fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r+");//建立密码
				fseek(ide, 68, SEEK_SET);
				printf("设置密码(100000--999999)\n");
				scanf_s("%d", &pa->Password[i]);
				fprintf(ide, "%d", pa->Password[i]);
				fclose(ide);
				system("cls");
				menu();
			}
			if (a != 0)
			{
				fseek(ide, 103, SEEK_SET);
				fscanf_s(ide, "%d", &a);
				if (a == 0)
				{
					fseek(ide, 103, SEEK_SET);
					printf("请设置账号(100000--999999)\n");
					scanf_s("%d", &pa->ID[i]);
					fprintf(ide, "%d", pa->ID[i]);
					fclose(ide);
					fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r+");//建立密码
					fseek(ide, 114, SEEK_SET);
					printf("设置密码(100000--999999)\n");
					scanf_s("%d", &pa->Password[i]);
					fprintf(ide, "%d", pa->Password[i]);
					fclose(ide);
					system("cls");
					menu();
				}
				if (a != 0)
				{
					fclose(ide);
					system("cls");
					printf("本银行用户名额已不足!!!\n");
					printf("系统即将自动返回主页面。\n");
					Sleep(5000);
					system("cls");
					menu();
				}
			}	
		}
}

void sanfang()//D:\\00ATM数据包v1.00\\user.ID.txt,D:\\00ATM数据包v1.00\\user.Password.txt,D:\\00ATM数据包v1.00\\user.Money.txt
{
	fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "w+");
	for (i = 1; i <= s; i++)
	{
		pa = RENA;
		fprintf(ide, "%d          %d          %d          %d          \n", pa->z[i] = i, pa->ID[i] = 0, pa->Password[i] = 0, pa->Money[i] = 0);
	}//%d          %d          %d          %d          \n
	fclose(ide);
	menu();
}
void menu2(int k)//具体业务面,副业面
{
	while (1)
	{
		int cho, a;
		printf("\n\n                  *************************************************\n                                    *简易ATM*\n\n\n                 *1.取款                                 *2.存款\n\n");
		printf("                 *3.查询                                 *4.修改信息\n\n                 *5.销户                                 *6.跨行业务\n\n                 *7.转账                                 *8.退出页面\n\n\n                  *************************************************\n\n");
		printf("                                  请选择服务项目\n                                        ");
		scanf_s("%d", &a);
		switch (a)
		{
		case 1: system("cls");
			quqian(k);
			break;
		case 2:system("cls");
			cunqian(k);
			break;
		case 3:system("cls");
			chaxun(k);
			break;
		case 4:system("cls");
			xiugai(k);
			break;
		case 5:system("cls");
			xiaohu(k);
			break;
		case 6:system("cls");
			//kuahang(k);
			exit(0);
			break;
		case 7:system("cls");
			zhuanzhang(k);
			break;
		case 8:system("cls");
			menu();
			break;
		default:system("cls"); menu2(k); break;
		}
	}
}
void quqian(int k)//取钱
{
	int a, b;
	pa = RENA;
	fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r");
	if (k == 1)
	{
		fseek(ide, 11, SEEK_SET);
		fscanf_s(ide, "%d ", &pa->ID[i]);
		printf("账户:%d \n", pa->ID[i]);
		fseek(ide, 33, SEEK_SET);
		fscanf_s(ide, "%d ", &pa->Money[i]);
		printf("余额:%d \n", pa->Money[i]);
		printf("请选择取出金额\n");
		scanf_s("%d", &a);
		fclose(ide);
		fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r+");
		fseek(ide, 33, SEEK_SET);
		fscanf_s(ide, "%d", &pa->Money[i] );
		if (pa->Money[i] - a >= 0)
		{
			for (b = 33; b <= 42; b++)
			{
				fseek(ide, b, SEEK_SET);
				fprintf(ide, " ", pa->Money[i]);
			}
			fseek(ide, 33, SEEK_SET);
			fprintf(ide, "%d", pa->Money[i] - a);
			system("cls");
			printf("余额:%d\n", pa->Money[i] - a);
			fclose(ide);
			printf("操作成功,即将返回副业面。\n");
			Sleep(5000);
			system("cls");
			menu2(k);
		}
		else
		{
			printf("余额不足,即将返回副页面。\n");
			Sleep(3000);
			system("cls");
			menu2(k);
		}
	}
	if (k == 2)
	{
		
		fseek(ide, 57, SEEK_SET);
		fscanf_s(ide, "%d ", &pa->ID[i]);
		printf("账户:%d \n", pa->ID[i]);
		fseek(ide, 79, SEEK_SET);
		fscanf_s(ide, "%d ", &pa->Money[i]);
		printf("余额:%d \n", pa->Money[i]);
		printf("请选择取出金额\n");
		scanf_s("%d", &a);
		fclose(ide);
		fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r+");
		fseek(ide, 79, SEEK_SET);
		fscanf_s(ide, "%d", &pa->Money[i] );
		if (pa->Money[i] - a >= 0)
		{
			for (b = 79; b <= 88; b++)
			{
				fseek(ide, b, SEEK_SET);
				fprintf(ide, " ", pa->Money[i]);
			}
			fseek(ide, 79, SEEK_SET);
			fprintf(ide, "%d", pa->Money[i] - a);
			system("cls");
			printf("余额:%d\n", pa->Money[i] - a);
			fclose(ide);
			printf("操作成功,即将返回副业面。\n");
			Sleep(3000);
			system("cls");
			menu2(k);
		}
		else
		{
			printf("余额不足,即将返回副页面。\n");
			Sleep(3000);
			system("cls");
			menu2(k);
		}
	}
	if (k == 3)
	{
		fseek(ide, 103, SEEK_SET);
		fscanf_s(ide, "%d ", &pa->ID[i]);
		printf("账户:%d \n", pa->ID[i]);
		fseek(ide, 125, SEEK_SET);
		fscanf_s(ide, "%d ", &pa->Money[i]);
		printf("余额:%d \n", pa->Money[i]);
		printf("请选择取出金额\n");
		scanf_s("%d", &a);
		fclose(ide);
		fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r+");
		fseek(ide, 125, SEEK_SET);
		fscanf_s(ide, "%d", &pa->Money[i] );
		if (pa->Money[i] - a >= 0)
		{
			for (b = 125; b <= 134; b++)
			{
				fseek(ide, b, SEEK_SET);
				fprintf(ide, " ", pa->Money[i]);
			}
			fseek(ide, 125, SEEK_SET);
			fprintf(ide, "%d", pa->Money[i] - a );
			system("cls");
			printf("余额:%d\n", pa->Money[i] - a );
			fclose(ide);
			printf("操作成功,即将返回副业面。\n");
			Sleep(3000);
			system("cls");
			menu2(k);
		}
		else
		{
			printf("余额不足,即将返回副页面。\n");
			Sleep(3000);
			system("cls");
			menu2(k);
		}
	}
	
}
void cunqian(int k)//存钱
{
	int a, b;
	pa = RENA;
	fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r");
	if (k == 1)
	{
		fseek(ide, 11, SEEK_SET);
		fscanf_s(ide, "%d ", &pa->ID[i]);
		printf("账户:%d \n", pa->ID[i]);
		fseek(ide, 33, SEEK_SET);
		fscanf_s(ide, "%d ", &pa->Money[i]);
		printf("余额:%d \n", pa->Money[i]);
		printf("请选择存入金额\n");
		scanf_s("%d", &a);
		fclose(ide);
		fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r+");
		fseek(ide, 33, SEEK_SET);
		fscanf_s(ide, "%d", &pa->Money[i] );
		for (b = 33; b <= 42; b++)
		{
			fseek(ide, b, SEEK_SET);
			fprintf(ide, " ", pa->Money[i]);
		}
		fseek(ide, 33, SEEK_SET);
		fprintf(ide, "%d", pa->Money[i] + a);
		system("cls");
		printf("余额:%d\n", pa->Money[i] + a);
		fclose(ide);
		printf("操作成功,即将返回副业面。\n");
		Sleep(3000);
		system("cls");
		menu2(k);

			
	}
	if (k == 2)
	{

		fseek(ide, 57, SEEK_SET);
		fscanf_s(ide, "%d ", &pa->ID[i]);
		printf("账户:%d \n", pa->ID[i]);
		fseek(ide, 79, SEEK_SET);
		fscanf_s(ide, "%d ", &pa->Money[i]);
		printf("余额:%d \n", pa->Money[i]);
		printf("请选择存入金额\n");
		scanf_s("%d", &a);
		fclose(ide);
		fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r+");
		fseek(ide, 79, SEEK_SET);
		fscanf_s(ide, "%d", &pa->Money[i]);
		for (b = 79; b <= 88; b++)
		{
			fseek(ide, b, SEEK_SET);
			fprintf(ide, " ", pa->Money[i]);
		}
		fseek(ide, 79, SEEK_SET);
		fprintf(ide, "%d", pa->Money[i] + a);
		system("cls");
		printf("余额:%d\n", pa->Money[i] + a);
		fclose(ide);
		printf("操作成功,即将返回副业面。\n");
		Sleep(3000);
		system("cls");
		menu2(k);
			
		
	}
	if (k == 3)
	{
		fseek(ide, 103, SEEK_SET);
		fscanf_s(ide, "%d ", &pa->ID[i]);
		printf("账户:%d \n", pa->ID[i]);
		fseek(ide, 125, SEEK_SET);
		fscanf_s(ide, "%d ", &pa->Money[i]);
		printf("余额:%d \n", pa->Money[i]);
		printf("请选择存入金额\n");
		scanf_s("%d", &a);
		fclose(ide);
		fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r+");
		fseek(ide, 125, SEEK_SET);
		fscanf_s(ide, "%d", &pa->Money[i]);
		for (b = 125; b <= 134; b++)
		{
			fseek(ide, b, SEEK_SET);
			fprintf(ide, " ", pa->Money[i]);
		}
		fseek(ide, 125, SEEK_SET);
		fprintf(ide, "%d", pa->Money[i] + a);
		system("cls");
		printf("余额:%d\n", pa->Money[i] + a);
		fclose(ide);
		printf("操作成功,即将返回副业面。\n");
		Sleep(3000);
		system("cls");
		menu2(k);		
	}
}
void chaxun(int k)//查询
{
	pa = RENA;
	fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r+");
	if (k == 1)
	{
		fseek(ide, 11, SEEK_SET);
		fscanf_s(ide, "%d ", &pa->ID[i]);
		printf("账户:%d \n", pa->ID[i]);
		fseek(ide, 33, SEEK_SET);
		fscanf_s(ide, "%d ", &pa->Money[i]);
		printf("余额:%d \n", pa->Money[i]);
	}
	if (k == 2)
	{
		fseek(ide, 57, SEEK_SET);
		fscanf_s(ide, "%d ", &pa->ID[i]);
		printf("账户:%d \n", pa->ID[i]);
		fseek(ide, 79, SEEK_SET);
		fscanf_s(ide, "%d ", &pa->Money[i]);
		printf("余额:%d \n", pa->Money[i]);
	}
	if (k == 3)
	{
		fseek(ide, 103, SEEK_SET);
		fscanf_s(ide, "%d ", &pa->ID[i]);
		printf("账户:%d \n", pa->ID[i]);
		fseek(ide, 125, SEEK_SET);
		fscanf_s(ide, "%d ", &pa->Money[i]);
		printf("余额:%d \n", pa->Money[i]);
	}
	fclose(ide);
	printf("即将自动跳转到副业面,请勿点击。\n");
	Sleep(7000);
	system("cls");
	menu2(k);
}
void xiugai(int k)//修改密码
{
	while (1)
	{
		int a, b;
		if (k == 1)
		{
			printf("请输入新密码:\n");
			scanf_s("%d", &a);
			printf("请再次输入新密码:\n");
			scanf_s("%d", &b);
			if (a == b) {
				fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r+");
				fseek(ide, 22, SEEK_SET);
				printf("请再次输入新密码:\n");
				scanf_s("%d", &pa->Password[i]);
				fprintf(ide, "%d", pa->Password[i]);
				fclose(ide);
				printf("修改成功,请重新登陆。\n");
				Sleep(5000);
				system("cls");
				menu();
			}
			else {
				system("cls");
				continue;
			}
		}
		if (k == 2)
		{
			printf("请输入新密码:\n");
			scanf_s("%d", &a);
			printf("请再次输入新密码:\n");
			scanf_s("%d", &b);
			if (a == b) {
				fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r+");
				fseek(ide, 68, SEEK_SET);
				printf("请再次输入新密码:\n");
				scanf_s( "%d", &pa->Password[i]);
				fprintf(ide, "%d", pa->Password[i]);
				fclose(ide);
				printf("修改成功,请重新登陆。\n");
				Sleep(5000);
				system("cls");
				menu();
			}
			else {
				system("cls");
				continue;
			}
		}
		if (k == 3)
		{
			printf("请输入新密码:\n");
			scanf_s("%d", &a);
			printf("请再次输入新密码:\n");
			scanf_s("%d", &b);
			if (a == b) {
				fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r+");
				fseek(ide, 114, SEEK_SET);
				printf("请再次输入新密码:\n");
				scanf_s("%d", &pa->Password[i]);
				fprintf(ide, "%d", pa->Password[i]);
				fclose(ide);
				printf("修改成功,请重新登陆。\n");
				Sleep(5000);
				system("cls");
				menu();
			}
			else {
				system("cls");
				continue;
			}
		}
	}
}
void xiaohu(int k)//销户
{
	int a, b;
	printf("确认销户?(确认输入1,取消输入0)\n");
	scanf_s("%d", &a);
	if (a == 1)
	{
		if (k == 1) {
			fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r+");
			fseek(ide, 11, SEEK_SET);
			for (b = 11; b <= 42; b++)
			{
				fseek(ide, b, SEEK_SET);
				fprintf(ide, " ", pa->Money[i]);
			}
			fseek(ide, 11, SEEK_SET);
			fprintf(ide, "%d", pa->ID[i] = 0);
			fseek(ide, 22, SEEK_SET);
			fprintf(ide, "%d", pa->ID[i] = 0);
			fseek(ide, 33, SEEK_SET);
			fprintf(ide, "%d", pa->ID[i] = 0);
		}
		if (k == 2) {
			fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r+");
			fseek(ide, 57, SEEK_SET);
			for (b = 57; b <= 88; b++)
			{
				fseek(ide, b, SEEK_SET);
				fprintf(ide, " ", pa->Money[i]);
			}
			fseek(ide, 57, SEEK_SET);
			fprintf(ide, "%d", pa->ID[i] = 0);
			fseek(ide, 68, SEEK_SET);
			fprintf(ide, "%d", pa->ID[i] = 0);
			fseek(ide, 79, SEEK_SET);
			fprintf(ide, "%d", pa->ID[i] = 0);
		}
		if (k == 3) {
			fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r+");
			fseek(ide, 103, SEEK_SET);
			for (b = 103; b <= 134; b++)
			{
				fseek(ide, b, SEEK_SET);
				fprintf(ide, " ", pa->Money[i]);
			}
			fseek(ide, 103, SEEK_SET);
			fprintf(ide, "%d", pa->ID[i] = 0);
			fseek(ide, 114, SEEK_SET);
			fprintf(ide, "%d", pa->ID[i] = 0);
			fseek(ide, 125, SEEK_SET);
			fprintf(ide, "%d", pa->ID[i] = 0);
		}
	}
	else
	{
		fclose(ide);
		system("cls");
		menu2(k);
	}
	fclose(ide);
	printf("销户成功,即将返回主页面。\n");
	Sleep(5000);
	system("cls");
	menu();
}

	
void zhuanzhang(int k)
{
	int a, b, c, d, e;
	fopen_s(&ide, "D:\\00ATMv2.00\\ATMv2.00.txt", "r+");
	if (k == 1) {
		fseek(ide, 33, SEEK_SET);
		fscanf_s(ide, "%d", &a);
		printf("余额:%d\n", a);
		fseek(ide, 57, SEEK_SET);
		fscanf_s(ide, "%d", &b);
		fseek(ide, 103, SEEK_SET);
		fscanf_s(ide, "%d", &c);
		printf("请输入您转账对象账号\n");
		scanf_s("%d", &d);
		if (d == b) {
			printf("请输入您的转账金额:\n");
			scanf_s("%d", &e);
			if (a - e >= 0) {
				fseek(ide, 33, SEEK_SET);
				fscanf_s(ide, "%d", &a);
				for (int f = 33; f <= 42; f++)
				{
					fseek(ide, f, SEEK_SET);
					fprintf(ide, " ", pa->Money[i]);
				}
				fseek(ide, 33, SEEK_SET);
				fprintf(ide, "%d", a - e);
				fseek(ide, 79, SEEK_SET);
				fscanf_s(ide, "%d", &b);
				for (int f = 79; f <= 88; f++)
				{
					fseek(ide, f, SEEK_SET);
					fprintf(ide, " ", pa->Money[i]);
				}
				fseek(ide, 79, SEEK_SET);
				fprintf(ide, "%d", b + e);
				printf("转账成功。\n");
				fclose(ide);
				Sleep(3000);
				system("cls");
				menu2(k);
			}
			if (a - e < 0) {
				printf("余额不足,转账失败。\n");
				fclose(ide);
				Sleep(3000);
				system("cls");
				menu2(k);
			}
		}
		if (d == c) {
			printf("请输入您的转账金额:\n");
			scanf_s("%d", &e);
			if (a - e >= 0) {
				fseek(ide, 33, SEEK_SET);
				fscanf_s(ide, "%d", &a);
				for (int f = 33; f <= 42; f++)
				{
					fseek(ide, f, SEEK_SET);
					fprintf(ide, " ", pa->Money[i]);
				}
				fseek(ide, 33, SEEK_SET);
				fprintf(ide, "%d", a - e);
				fseek(ide, 125, SEEK_SET);
				fscanf_s(ide, "%d", &b);
				for (int f = 125; f <= 134; f++)
				{
					fseek(ide, f, SEEK_SET);
					fprintf(ide, " ", pa->Money[i]);
				}
				fseek(ide, 125, SEEK_SET);
				fprintf(ide, "%d", b + e);
				printf("转账成功。\n");
				fclose(ide);
				Sleep(3000);
				system("cls");
				menu2(k);
			}
			if (a - e < 0) {
				printf("余额不足,转账失败。\n");
				fclose(ide);
				Sleep(3000);
				system("cls");
				menu2(k);
			}
		}
		else
		{
			system("cls");
			menu2(k);
		}
	}
	if (k == 2) {
		fseek(ide, 79, SEEK_SET);
		fscanf_s(ide, "%d", &a);
		printf("余额:%d\n", a);
		fseek(ide, 11, SEEK_SET);
		fscanf_s(ide, "%d", &b);
		fseek(ide, 103, SEEK_SET);
		fscanf_s(ide, "%d", &c);
		printf("请输入您转账对象账号\n");
		scanf_s("%d", &d);
		if (d == b) {
			printf("请输入您的转账金额:\n");
			scanf_s("%d", &e);
			if (a - e >= 0) {
				fseek(ide, 79, SEEK_SET);
				fscanf_s(ide, "%d", pa->Money);
				for (int f = 79; f <= 88; f++)
				{
					fseek(ide, f, SEEK_SET);
					fprintf(ide, " ", pa->Money[i]);
				}
				fseek(ide, 79, SEEK_SET);
				fprintf(ide, "%d", a - e);
				fseek(ide, 33, SEEK_SET);
				fscanf_s(ide, "%d", &b);
				for (int f = 33; f <= 42; f++)
				{
					fseek(ide, f, SEEK_SET);
					fprintf(ide, " ", pa->Money[i]);
				}
				fseek(ide, 33, SEEK_SET);
				fprintf(ide, "%d", b + e);
				printf("转账成功。\n");
				fclose(ide);
				Sleep(3000);
				system("cls");
				menu2(k);
			}
			if (a - e < 0) {
				printf("余额不足,转账失败。\n");
				fclose(ide);
				Sleep(3000);
				system("cls");
				menu2(k);
			}
		}
		if (d == c) {
			printf("请输入您的转账金额:\n");
			scanf_s("%d", &e);
			if (a - e >= 0) {
				fseek(ide, 79, SEEK_SET);
				fscanf_s(ide, "%d", pa->Money);
				for (int f = 79; f <= 88; f++)
				{
					fseek(ide, f, SEEK_SET);
					fprintf(ide, " ", pa->Money[i]);
				}
				fseek(ide, 79, SEEK_SET);
				fprintf(ide, "%d", a - e);
				fseek(ide, 125, SEEK_SET);
				fscanf_s(ide, "%d", &b);
				for (int f = 125; f <= 134; f++)
				{
					fseek(ide, f, SEEK_SET);
					fprintf(ide, " ", pa->Money[i]);
				}
				fseek(ide, 125, SEEK_SET);
				fprintf(ide, "%d", b + e);
				printf("转账成功。\n");
				fclose(ide);
				Sleep(3000);
				system("cls");
				menu2(k);
			}
			if (a - e < 0) {
				printf("余额不足,转账失败。\n");
				fclose(ide);
				Sleep(3000);
				system("cls");
				menu2(k);
			}
		}
		else
		{
			system("cls");
			menu2(k);
		}
	}
	if (k == 3) {
		fseek(ide, 125, SEEK_SET);
		fscanf_s(ide, "%d", &a);
		printf("余额:%d\n", a);
		fseek(ide, 11, SEEK_SET);
		fscanf_s(ide, "%d", &b);
		fseek(ide, 57, SEEK_SET);
		fscanf_s(ide, "%d", &c);
		printf("请输入您转账对象账号\n");
		scanf_s("%d", &d);
		if (d == b) {
			printf("请输入您的转账金额:\n");
			scanf_s("%d", &e);
			if (a - e >= 0) {
				fseek(ide, 125, SEEK_SET);
				fscanf_s(ide, "%d", pa->Money);
				for (int f = 125; f <= 134; f++)
				{
					fseek(ide, f, SEEK_SET);
					fprintf(ide, " ", pa->Money[i]);
				}
				fseek(ide, 125, SEEK_SET);
				fprintf(ide, "%d", a - e);
				fseek(ide, 33, SEEK_SET);
				fscanf_s(ide, "%d", &b);
				for (int f = 33; f <= 42; f++)
				{
					fseek(ide, f, SEEK_SET);
					fprintf(ide, " ", pa->Money[i]);
				}
				fseek(ide, 33, SEEK_SET);
				fprintf(ide, "%d", b + e);
				printf("转账成功。\n");
				fclose(ide);
				Sleep(3000);
				system("cls");
				menu2(k);
			}
			if (a - e < 0) {
				printf("余额不足,转账失败。\n");
				fclose(ide);
				Sleep(3000);
				system("cls");
				menu2(k);
			}
		}
		if (d == c) {
			printf("请输入您的转账金额:\n");
			scanf_s("%d", &e);
			if (a - e >= 0) {
				fseek(ide, 125, SEEK_SET);
				fscanf_s(ide, "%d", pa->Money);
				for (int f = 125; f <= 134; f++)
				{
					fseek(ide, f, SEEK_SET);
					fprintf(ide, " ", pa->Money[i]);
				}
				fseek(ide, 125, SEEK_SET);
				fprintf(ide, "%d", a - e);
				fseek(ide, 79, SEEK_SET);
				fscanf_s(ide, "%d", &b);
				for (int f = 79; f <= 88; f++)
				{
					fseek(ide, f, SEEK_SET);
					fprintf(ide, " ", pa->Money[i]);
				}
				fseek(ide, 79, SEEK_SET);
				fprintf(ide, "%d", b + e);
				printf("转账成功。\n");
				fclose(ide);
				Sleep(3000);
				system("cls");
				menu2(k);
			}
			if (a - e < 0) {
				printf("余额不足,转账失败。\n");
				fclose(ide);
				Sleep(3000);
				system("cls");
				menu2(k);
			}
		}
		else
		{
			system("cls");
			menu2(k);
		}
	}
}
int main()//2020-11-21  15:49
{
	menu();
	system("pause");
	return 0;
}

 

你可能感兴趣的:(c,c++)