Mundarija: kirish




Download 25,53 Kb.
bet7/7
Sana21.01.2024
Hajmi25,53 Kb.
#142631
1   2   3   4   5   6   7
Bog'liq
Аptеkаdа dоrilаrning kirim-chiqim vа qоldiq хisоbini yuritish-fayllar.org
photo 2022-08-23 11-09-50, 15051, quiz javoblari, 713-19 Raxmonova M lab 1-2-3 ratmoq xavfsizligi, abdumannnonov asadbek, ABDUXOLIQ G, O’qituvchining tarbiyachilik mahorati, 1-mustaqil ish CHA, 2-mustaqil ish CHA, «Утилиты обслуживание и оптимизация компьютера», Algebraik amallar va ularning xossalari. Ta`rif (1), Materiallar qarshiligi, ilhomjon axmadaliyev crecor, Kinds of arts, jismoniy-shaxslardan-olinadigan-mol-mulk-solig-ini-mexanizmini-takomillashtirish-yo-llari
INTERNET MANBALARI: 
www.cyber-form.ru

www.wikipedia.org


www.programmer.com

www.dastur.uz


www.w3schools.com
www.cplusplus.com





ILOVA. 
Dasturning kod qismi 
#include
#include
#include
using namespace std;
int n,k=0;
string komp[1000][2];
int narxi[1000][2];
//Funksiyalar nomi
void menyu();
void info();
void add();
void change();
void buy();
void line();
int load();
bool tek(char *filename);
//Dastur asosiy qismi boshlandi.
int main()
{
if(!tek("baza.txt"))
{
ofstream fayl("baza.txt");
}
k=load();



line();
cout << "APTEKA !\n";


qayt:
menyu();
cout << "Kerakli raqamni kiriting:"; cin >> n;
switch(n)
{
case 1: info(); break;
case 2: add(); break;
case 3: change(); break;
case 4: buy(); break;
case 5:
{
ofstream fayl("baza.txt");
for(int i=1; i<=k; i++)
{
//fayl << i; fayl << "";
fayl fayl.close();
system("cls");
cout << "Barcha ma'lumotlar baza.txt fayliga yozib qo'yildi!\n";
system("pause");
return 0; break;
}
default: cout << "\nBunday buyruq yo'q!\n";



}
goto qayt;


return 0;
}
//Dastur asosiy qismi tugadi. Funksiyalar boshlandi
bool tek(char *filename)
{
ifstream ifile(filename);
return (bool)ifile;
}
int load()
{
ifstream f("baza.txt");
string s;
int k=0;
while(!f.eof())
{
k++;
getline(f, s);
switch(k%4)
{
case 1: komp[k/4+1][0]=s; break;
case 2: komp[k/4+1][1]=s; break;
case 3: narxi[k/4+1][0]=atoi(s.c_str()); break;
// String s dan int i ga o'tish ==> i=atoi(s.c_str());
case 0: narxi[k/4][1]=atoi(s.c_str()); break;
default: break;
}
}



f.close();


return k/4;
}
void buy()
{
info();
int soni,s=0;
cout << "QANCHA MAHSULOT sotib olmoqchisiz? "; cin >> soni;
for(int i=1; i<=soni; i++)
{
int t,n; cout << "MAHSULOT tartib raqamini kiring: "; cin >> t;
cout << komp[t][0] << "dan nechta? "; cin >> n;
if(narxi[t][1]{
cout << komp[t][0] << "dan " << narxi[t][1] << " ta qolgan. Sizga " << narxi[t][1] << " ta berildi!" <<
endl}
else
{
s+=n*narxi[t][0];
narxi[t][1]-=n;
}
}
line();
cout << "Jami summa: " << s << endl << endl;
}
void change()
{



info();
int t;


cout << "MAXSULOT tartib raqamini kiriting: "; cin >> t;
if(t>k)
{
cout << "Bunday maxsulot mavjud emas!\n";
} else
{
cout << "maxsulot nomi: "; cin >> komp[t][0];
cout << "Tavsifi: "; getline(cin, komp[t][1]); getline(cin, komp[t][1]);
cout << "Qancha: "; cin >> narxi[t][0];
cout << "Soni: "; cin >> narxi[t][1];
line();
cout << "maxsulot o'zgartirildi!\n" << endl << endl;
}
}
void add()
{
system("cls");
line();
k++; bool ok=false; int t,p;
cout << "maxsulot nomi: "; cin >> komp[k][0];
for(int i=1; i<=k-1; i++)
{
if(komp[k][0]==komp[i][0])
{
ok=ok|true;
t=i;
break;



}
}


if(ok)
{
cout<>p;
narxi[t][1]+=p; k--;
}
else
{
cout << "Tavsifi: "; getline(cin, komp[k][1]); getline(cin, komp[k][1]);
cout << "Narxi: "; cin >> narxi[k][0];
cout << "Soni: "; cin >> narxi[k][1];
}
line();
cout << "maxsulot qo'shildi!\n" << endl << endl;
}
void info()
{
system("cls");
int s=0;
line();
if (k==0) cout << "Hech qanday maxsulot topilmadi!"<< endl << endl;
else
for (int i=1; i<=k; i++)
{
cout << "Raqami:\t" << i << "\n";
cout << "Nomi:\t" << komp[i][0] << "\n";
cout << "Tavsif:\t" << komp[i][1] << "\n";
cout << "Narxi:\t" << narxi[i][0] << endl;



cout << "Soni:\t"<< narxi[i][1]<< endl;


s+=narxi[i][0]*narxi[i][1];
line();
}
cout <<"Magazinda umumiy narxi "<}
void line()
{
for(int i=0; i<60; i++)
cout << "_";
cout << endl << endl;
}
void menyu()
{
line();
cout << "1. maxsulotlar haqida ma'lumot" cout << "5. Chiqish" <}

http://fayllar.org



Download 25,53 Kb.
1   2   3   4   5   6   7




Download 25,53 Kb.