关于诸如此类的什么管理系统(更新)

       2019.7.12更新记录:

       很多人过来吐槽我之前写的代码又臭又长,所以今天更新了以下,着实没有改多少东西,但是好评多了根多,打算回头写个C++类版本的

       也没要求谁下载,更没要求谁出积分,直接公开,登录csdn号就直接复制粘贴就行

codeblocks替换文本快捷键为:ctrl+R

屎丢丢替换文本快捷键为:ctrl+h

源码丢在这里了:

/*C++结构体版本,附带注释*/
/*
v0.3更新日志:2019.6.30更新。
主要更新内容有:
1、将原有的输入部分,输出部分改成了内联函数,减少代码,运行更快
2、输入输出内容只需要在这两个函数里面改就行了
3、尝试更改下个版本加入类内容
4、尝试更改下个版本变成窗口化生成代码,鼠标戳一戳就行
5、其实没干多少东西,但是写注释比较爽,索性就写写了
~OuO~
*/
//VS常用快捷键:顺序按下 ctrl+k ctrl+d——自动整理代码格式
//ctrl+h——快速替换文本,如果有选中部分就默认只替换选中部分,反之全局替换,包括注释也会被替换掉
//Codeblocks常用快捷键:alt+l 召唤出菜单,选择Astyle,可以自动整理代码格式
//ctrl+r——快速替换文本,效果同上
#include
#include
#include
#define MAXN 1000//最大能存入多少管理对象
using namespace std;

int Count = 0;

struct Tem
{
	char s1[30];
	char s2[30];
	char s3[30];
	char s4[30];
	char s5[30];
	char s6[30];
	char s7[30];
	char s8[30];
	char s9[30];
	char s10[30];//预留的十个字符数组
	int int_num1;
	int int_num2;
	int int_num3;
	int int_num4;
	int int_num5;//预留的五个整数
	double double_num1;
	double double_num2;
	double double_num3;
	double double_num4;
	double double_num5;//预留5个小数
	int status;//状态标志,0为不存在,非零为反
}tem[MAXN];

inline void insert(int index)//输入函数
{
	cout << "请输入s1:" << endl;
	cin >> tem[index].s1;
	cout << "请输入s2:" << endl;
	cin >> tem[index].s2;
	cout << "请输入s3:" << endl;
	cin >> tem[index].s3;
	cout << "请输入s4:" << endl;
	cin >> tem[index].s4;
	cout << "请输入s5:" << endl;
	cin >> tem[index].s5;
	cout << "请输入s6:" << endl;
	cin >> tem[index].s6;
	cout << "请输入s7:" << endl;
	cin >> tem[index].s7;
	cout << "请输入s8:" << endl;
	cin >> tem[index].s8;
	cout << "请输入s9:" << endl;
	cin >> tem[index].s9;
	cout << "请输入s10:" << endl;
	cin >> tem[index].s10;
	cout << "请输入int_int_num1:" << endl;
	cin >> tem[index].int_num1;
	cout << "请输入int_num2:" << endl;
	cin >> tem[index].int_num2;
	cout << "请输入int_num3:" << endl;
	cin >> tem[index].int_num3;
	cout << "请输入int_num4:" << endl;
	cin >> tem[index].int_num4;
	cout << "请输入int_num5:" << endl;
	cin >> tem[index].int_num5;
	cout << "请输入double_int_num1:" << endl;
	cin >> tem[index].double_num1;
	cout << "请输入double_num2:" << endl;
	cin >> tem[index].double_num2;
	cout << "请输入double_num3:" << endl;
	cin >> tem[index].double_num3;
	cout << "请输入double_num4:" << endl;
	cin >> tem[index].double_num4;
	cout << "请输入double_num5:" << endl;
	cin >> tem[index].double_num5;
}

inline void output(int index)//输出函数
{
	cout << "s1:" << tem[index].s1 << endl;
	cout << "s2:" << tem[index].s2 << endl;
	cout << "s3:" << tem[index].s3 << endl;
	cout << "s4:" << tem[index].s4 << endl;
	cout << "s5:" << tem[index].s5 << endl;
	cout << "s6:" << tem[index].s6 << endl;
	cout << "s7:" << tem[index].s7 << endl;
	cout << "s8:" << tem[index].s8 << endl;
	cout << "s9:" << tem[index].s9 << endl;
	cout << "s10:" << tem[index].s10 << endl;
	cout << "int_num1:" << tem[index].int_num1 << endl;
	cout << "int_num2:" << tem[index].int_num2 << endl;
	cout << "int_num3:" << tem[index].int_num3 << endl;
	cout << "int_num4:" << tem[index].int_num4 << endl;
	cout << "int_num5:" << tem[index].int_num5 << endl;
	cout << "double_num1:" << tem[index].double_num1 << endl;
	cout << "double_num2:" << tem[index].double_num2 << endl;
	cout << "double_num3:" << tem[index].double_num3 << endl;
	cout << "double_num4:" << tem[index].double_num4 << endl;
	cout << "double_num5:" << tem[index].double_num5 << endl;
}

void insert_function()//增加函数
{
	insert(Count);
	tem[Count].status = 1;
	Count++;
}

void find_function()//查找函数
{
	int flag = 0;
	char Name[30];
	cout << "请输入是s1:" << endl;
	cin >> Name;
	for (int i = 0; i < Count; i++)
	{
		if (strcmp(Name, tem[i].s1) == 0 && tem[i].status)
		{
			flag = 1;
			output(i);
			break;
		}
	}
	if (!flag)
	{
		cout << "查无此人" << endl;
	}
}

void del_function()//删除函数
{
	int flag = 0;
	char Name[30];
	cout << "请输入是s1:" << endl;
	cin >> Name;
	for (int i = 0; i < Count; i++)
	{
		if (strcmp(Name, tem[i].s1) == 0 && tem[i].status)
		{
			flag = 1;
			output(i);
			tem[i].status = 0;
			cout << "已删除" << endl;
			break;
		}
	}
	if (!flag)
	{
		cout << "查无此人" << endl;
	}
}

void change_function()//修改函数
{
	int flag = 0;
	char Name[30];
	cout << "请输入是s1:" << endl;
	cin >> Name;
	for (int i = 0; i < Count; i++)
	{
		if (strcmp(Name, tem[i].s1) == 0 && tem[i].status)
		{
			flag = 1;
			output(i);
			insert(i);
			break;
		}
	}
	if (!flag)
	{
		cout << "查无此人" << endl;
	}
}

void save_function()//储存文件函数
{
	FILE *fp = fopen("save.txt", "w+");
	for (int i = 0; i < Count; i++)
	{
		if (tem[i].status)
		{
			fwrite(&tem[i], sizeof(struct Tem), 1, fp);
		}
	}
	fclose(fp);
}

void read_function()//读取文件函数
{
	FILE *fp = fopen("save.txt", "r");
	if (fp == NULL)
	{
		fp = fopen("save.txt", "w+");
		fclose(fp);
		return;
	}
	Count = 0;
	while (!feof(fp))
	{
		fread(&tem[Count++], sizeof(struct Tem), 1, fp);
	}
	fclose(fp);
}

int main()
{
	read_function();
	while (1)
	{
		cout << "\t\t\t\tXXXXXXXX管理系统" << endl;
		cout << "\t\t\t\t 1.增加XXXX信息" << endl;
		cout << "\t\t\t\t 2.删除XXXX信息" << endl;
		cout << "\t\t\t\t 3.修改XXXX信息" << endl;
		cout << "\t\t\t\t 4.查询XXXX信息" << endl;
		cout << "\t\t\t\t  5.退出系统" << endl;
		cout << "请选择:" << endl;
		int i;
		cin >> i;
		switch (i)
		{
		case 1:
			system("cls");
			insert_function();
			system("pause");
			system("cls");
			break;
		case 2:
			system("cls");
			del_function();
			system("pause");
			system("cls");
			break;
		case 3:
			system("cls");
			change_function();
			system("pause");
			system("cls");
			break;
		case 4:
			system("cls");
			find_function();
			system("pause");
			system("cls");
			break;
		default:
			save_function();
			exit(0);
			break;
		}
	}
	return 0;
}
/*write by:Elliot Alderson*/

喜欢的话可以随意拿走,不用滴滴我说能不能用什么的,不定期公开新的东西

你可能感兴趣的:(开源源码)