Foydalanilgan adabiyotlar
B.B Mo’minov “Dasturlash I”
Qudrat Abduraxmonov “C++ dasturlash tili”
Internet manbalari:
www.cyber-form.ru
www.wikipedia.org
www.programmer.com
W3schools.com
Tutorial.com
Edx.org.com
ILOVA.
Dasturning ko’d qismi
#include
#include
#include
#include
#include
#include
using namespace std;
void Show_Date() {
time_t now = time(0);
struct tm * timeinfo = localtime(&now);
cout << "\t" << timeinfo->tm_mday << "." << timeinfo->tm_mon + 1
<< "." << 1900 + timeinfo->tm_year << "\n";
}
int stoi(string text) {
stringstream conv(text);
int x;
conv >> x;
return x;
}
void Show_Employees(){
ifstream efile("employees.txt");
string line;
if (!getline(efile, line) || !efile)
cout << "Ma'lumot mavjud emas";
else {
cout << line << "\n";
while(getline(efile, line)){
cout << line << "\n";
}
}
efile.close();
}
void Add_New() {
cout << "\t Yangi a'zo \n";
cout << "A'zo ismi va familyasi : ";
string name;
cin.ignore();
getline(cin, name);
cout << "\n!!! Ogohlantirish !!!\n";
cout << "*Yangi a'zo qo'shilganda a'zolar jadvali qayta tuziladi.\n\n";
cout << "Yangi a'zo qo'shilsinmi? (1-Ha, 2-yo'q)\n";
int n;
cin >> n;
if (n == 2) {
cout << "Bekor qilindi!\n";
return;
}
ofstream efile("employees.txt", ios::app);
string line;
if (!efile){
cout << "Xatolik 404\n";
return;
}
efile << name << endl;
cout << "Muvaffaqiyatli qo'shildi!\n";
efile.close();
}
void Update() {
ifstream file("last.txt");
ifstream efile("employees.txt");
ofstream lfile("log.txt", ios::app);
string line;
getline(file, line);
file.close();
int month = stoi(line.substr(0,2));
string syear = line.substr(2,4);
int year = stoi(syear);
string current = line.erase(0,6);
time_t now = time(0);
struct tm * timeinfo = localtime(&now);
timeinfo->tm_year += 1900;
ostringstream text;
if ((year < timeinfo->tm_year) || (timeinfo->tm_mon > month)) {
while (getline(efile, line) && (line != current)) {cout<<"inwhile\n";}
for (int i = 1; i <= (timeinfo->tm_mon - month); i++) {
cout << "infor\n";
getline(efile, line);
month += 1;
string t;
if (month < 10) {
text << month;
lfile << "0" << text.str() << syear << line << endl;
}
else
lfile << text.str() << syear << line << endl;
}
ofstream rfile("last.txt");
if (month < 10) {
//text << month;
rfile << "0" << text.str() << syear << line << endl;
cout << "0" << text.str() <
}
else
rfile << text.str() << syear << line << endl;
}
file.close();
efile.close();
lfile.close();
}
string Get_Last() {
ifstream file("last.txt");
string linee;
if (!getline(file, linee))
return "Ma'lumot mavjud emas";
else {
linee.erase(linee.begin(),linee.begin()+6);
return linee;
}
file.close();
}
string Month(int mon) {
if (mon == 0) return 0;
}
void Xodimlar() {
ifstream file("log.txt");
string line;
if (!getline(file, line) || !file)
cout << "Ma'lumot mavjud emas";
else {
int month = stoi(line.substr(0,2));
int year = stoi(line.substr(2,7));
line.erase(0,6);
cout << line <
while (getline(file, line)) {
int month = stoi(line.substr(0,2));
int year = stoi(line.substr(2,7));
line.erase(0,6);
cout << line << endl ;
}
}
file.close();
}
void Future() {
ifstream efile("employees.txt");
ifstream lfile("last.txt");
string line;
getline(lfile, line);
int month = stoi(line.substr(0,2));
int year = stoi(line.substr(2,7));
string current = line.erase(0,6);
bool show = false;
while (getline(efile, line)) {
if (line == current) {
show = true;
getline(efile, line);
}
if (show) {
if (month == 11) {
month = -1;
year += 1;
}
month += 1;
cout << line << "\t- " << Month(month) << " " << year << "-yil\n";
}
}
if (!show)
cout << "Ma'lumot mavjud emas\n";
efile.close();
lfile.close();
}
int main(int argc, char** argv) {
Update();
main:
system("cls");
cout << "\t Kutubxona nomi: "; cout<<"Abduraxmon Jomiy"<
cout << "Kutubxona nazoratchisi : " <<" Toshpo'latov Asros "<< endl;
cout << "\n1.Kutubxona xodimlari jadvali\n";
cout << "2.Kutubxonaga a'zolar ro'yhati\n";
cout << "3.Yangi a'zo qo'shish\n";
cout << "4.Dasturdan chiqish\n";
cout << "Bo'limni tanllang : " ;
int num;
cin >> num;
if (num == 2) {
system("cls");
cout << "\t A'zolar ro'yhati\n";
Show_Employees();
cout << "\n*Qaytish -1-\n";
cin >> num;
goto main;
}
else if (num == 3) {
system("cls");
Add_New();
cout << "\n*Qaytish -1-\n";
cin >> num;
goto main;
}
else if (num == 1) {
system("cls");
cout << "\tXodimlar jadvali:\n";
Xodimlar();
cout << "\n*Qaytish -1-\n";
cin >> num;
goto main;
}
return 0;}
Do'stlaringiz bilan baham: |