当前位置:网站首页>What management systems (Updates) for things like this

What management systems (Updates) for things like this

2022-06-26 05:28:00 Elliot_ Alderson

       2019.7.12 Update record :

        Many people come to roast that the code I wrote before is smelly and long , So today we updated the following , It really hasn't changed much , But there are many good reviews , I'm going to write back C++ Class version

        No one is required to download , No one is required to give points , Direct disclosure , Sign in csdn Just copy and paste

codeblocks Replace the text shortcut key with :ctrl+R

Replace the text shortcut key with :ctrl+h

The source code is left here :

/*C++ Structure version , With notes */
/*
v0.3 Update log :2019.6.30 to update .
 The main updates are :
1、 Put the original input part , The output part is changed to an inline function , Reduce code , Run faster 
2、 The input and output contents only need to be changed in these two functions 
3、 Try changing the next version to include class content 
4、 Try changing the next version to windowed generated code , Just poke the mouse 
5、 Actually, I didn't do much , But it's cool to write notes , Just write 
~OuO~
*/
//VS Common shortcut key : Sequential press  ctrl+k ctrl+d—— Automatic code formatting 
//ctrl+h—— Quick replace text , If there is a selected part, only the selected part will be replaced by default , On the contrary, global replacement , Including comments will also be replaced 
//Codeblocks Common shortcut key :alt+l  Call out the menu , choice Astyle, Can automatically organize the code format 
//ctrl+r—— Quick replace text , The effect same as above 
#include<iostream>
#include<string>
#include<algorithm>
#define MAXN 1000// The maximum number of management objects can be stored 
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];// Reserved ten character array 
	int int_num1;
	int int_num2;
	int int_num3;
	int int_num4;
	int int_num5;// Five integers reserved 
	double double_num1;
	double double_num2;
	double double_num3;
	double double_num4;
	double double_num5;// reserve 5 Decimals 
	int status;// Status flag ,0 For there is no such thing , Nonzero is negative 
}tem[MAXN];

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

inline void output(int index)// Output function 
{
	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()// Add function 
{
	insert(Count);
	tem[Count].status = 1;
	Count++;
}

void find_function()// Lookup function 
{
	int flag = 0;
	char Name[30];
	cout << " Please enter yes 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 << " Check no one " << endl;
	}
}

void del_function()// Delete function 
{
	int flag = 0;
	char Name[30];
	cout << " Please enter yes 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 << " deleted " << endl;
			break;
		}
	}
	if (!flag)
	{
		cout << " Check no one " << endl;
	}
}

void change_function()// Modify the function 
{
	int flag = 0;
	char Name[30];
	cout << " Please enter yes 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 << " Check no one " << endl;
	}
}

void save_function()// Save file functions 
{
	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()// Read file 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 Management system " << endl;
		cout << "\t\t\t\t 1. increase XXXX Information " << endl;
		cout << "\t\t\t\t 2. Delete XXXX Information " << endl;
		cout << "\t\t\t\t 3. modify XXXX Information " << endl;
		cout << "\t\t\t\t 4. Inquire about XXXX Information " << endl;
		cout << "\t\t\t\t  5. Exit the system " << endl;
		cout << " Please select :" << 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*/

You can take it away if you like , Don't tell me if I can use something , Open new things from time to time

原网站

版权声明
本文为[Elliot_ Alderson]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202180506069267.html