Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
2.7 kB
5
Indexable
Never
#include <bits/stdc++.h>
using namespace std;
string a[100][4];
int sk = 0;
void Xoa()
{
	string x;
	bool check = false;
	cout << "Nhap ten su kien can xoa: "; getline(cin,x);
	for (int i=0; i<sk; i++)
	{
		if (x.compare(a[i][1])==0)
		{
			int vt = i;
			for (int j = vt; vt <sk-1; vt++)
			{
				a[j][0] = a[j+1][0];
				a[j][1] = a[j+1][1];
				a[j][2] = a[j+1][2];
				a[j][3] = a[j+1][3];
				a[j][4] = a[j+1][4];
			}
			check = true;
			sk--;
			break;
		}
	}
	if (check == true) cout <<"Thuc hien sua doi thanh cong. \n";
	else cout << "Khong tim thay su kien nay.\n";
}
void Sua()
{
	string x;
	bool check = false;
	cout << "Nhap ten su kien can chinh sua: "; getline(cin,x);
	for (int i=0; i<sk; i++)
		{
			if (x.compare(a[i][1]) == 0)
			{
				cout << "Nhap ngay dien ra: "; getline(cin,a[i][0]);
				cout << "Nhap ten su kien: "; getline(cin,a[i][1]);
				cout << "Nhap noi dung su kien: "; getline(cin,a[i][2]);
				cout << "Nhap dia diem su kien: "; getline(cin,a[i][3]);
				cout << "Nhap hop dong su kien: "; getline(cin,a[i][4]);
				check = true;
				break;
			}
		}
	if (check == true) cout <<"Thuc hien sua doi thanh cong. \n";
	else cout << "Khong tim thay su kien nay.\n";
}
void Nhap()
{
	cout << "Nhap ngay dien ra: "; getline(cin,a[sk][0]);
	cout << "Nhap ten su kien: "; getline(cin,a[sk][1]);
	cout << "Nhap noi dung su kien: "; getline(cin,a[sk][2]);
	cout << "Nhap dia diem su kien: "; getline(cin,a[sk][3]);
	cout << "Nhap hop dong su kien: "; getline(cin,a[sk][4]);
	sk++;
}
void In()
{
	for (int i=0; i<sk; i++){
			cout << "Ngay dien ra: "<< a[i][0] << endl;
			cout << "Ten su kien: "<< a[i][1] << endl;
			cout << "Noi dung su kien: "<< a[i][2] << endl;
			cout << "Dia diem su kien: "<< a[i][3] << endl;
			cout << "Hop dong su kien: "<< a[i][4] << endl;
	}
}
void In1()
{
	cout << "Ngay\t\tTen\t\tNoi Dung\t\tDia Diem\tHop Dong\n";
	for (int i=0; i<sk; i++) cout << a[i][0] << "\t" << a[i][1] << "\t" << a[i][2] << "\t\t" << a[i][3] << "\t\t" << a[i][4] << endl;
}
void Menu()
{
	bool kt_menu = true;
	while(kt_menu)
	{
		system("cls");
		cout << "\t\t=====Quan li KOL=====\n";
		cout << "\t\t1.Hien thi\n";
		cout << "\t\t2.Them\n";
		cout << "\t\t3.Sua\n";
		cout << "\t\t4.Xoa\n";
		cout << "\t\t0.Thoat\n";
		int lc;
		cout << "\nChon chuc nang: ";
		cin >> lc;
		cin.ignore();
		switch(lc)
		{
			case 1:
			{
				In();
				system("pause");
				break;
			}
			case 2:
			{
				Nhap();
				break;
			}
			case 3:
			{
				Sua();
				break;
			}
			case 4:
			{
				Xoa();
				break;
			}
			case 0:
			{
				kt_menu = false;
				break;
			}
		}
	}
}
int main()
{
	Menu();
}