O‘zbekiston Respublikasi axborot texnologiyalari va kommunikatsiyalarini rivojlantirish vazirligi Muhammad al-Xorazmiy nomidagi Toshkent axborot texnologiyalari universiteti
Informatika fani kafedrasi Dasturlash fani bo`yicha
6- Laboratoriya ishi
Bajardi: 005-L3 - guruh talabasi Omonov Kamoliddin
Tekshirdi: Baxromova Yulduz
1 – misol:
#include
#include
#include
#include
#include
using namespace std;
class Computer_mouses {
public :
string type;
string name;
string colour;
string place_of_made;
string shape;
string extra_facilities;
string name_of_company;
int year_of_made;
float cost;
float weight;
Computer_mouses () {}
};
int main ()
{
/*Class ni random funksiyasi bilan to'ldirish*/
srand(time(0));
Computer_mouses S[50];
int n;
cout << "Sichqonchalarning sonini kiriting: "; cin >> n;
string turlar[4] = {"simli", "simsiz", "optik tolali", "sensorli"};
string nomlar[4] = {"Kenya", "Combo", "Rembo" "Kroosalt"};
string ranglar[6] = {"qora", "kulrang", "oq", "kok", "siyohrang", "havorang"};
string davlatlar[8] = {"America", "Koreya", "Xitoy", "Ozbekiston", "Hindiston", "Rossiya", "Kanada", "Germaniya"};
string shakllar[6] = {"car", "shoes", "pult", "ball", "ordinary", "mice"};
string imkoniyatlar[5] = {"qulayligi", "moslashuvchanligi", "chidamliligi", "yorqinliligi", "o'lchami"};
string kompaniyalar[6] = {"Amazon", "Microsoft", "Facebook", "MaxPro", "Alibaba", "Aliexpress"}; cout << "Jadvalda quyidagi qisqartirishlar mavjud:" << endl;
cout << "Turi : T Nomi : N Rangi : R Ishlab_chiqarilgan_joyi : J Shakli : SH Qo'shimcha_imkoniyatlarti : I Ishlab_chiqargan_kompaniyasi : K Yili : Y Narxi : C Og'irligi : O \n" << endl;
cout << "Jadval ko'rinishi: " << endl;
cout << setw(15) << "T" << setw(15) << "N" << setw(15) << "R" << setw(15) << "J" << setw(15) << "SH" << setw(20) << "I" << setw(15) << "K" << setw(15) << "Y" << setw(15) << "C" << setw(15) << "O" << endl;
for (int i = 0; i < n; i++) {
S[i].type = turlar[rand() % 3];
S[i].name = nomlar[rand() % 3];
S[i].colour = ranglar[rand() % 5];
S[i].place_of_made = davlatlar[rand() % 7];
S[i].shape = shakllar[rand() % 5];
S[i].extra_facilities = imkoniyatlar[rand() % 4];
S[i].name_of_company = kompaniyalar[rand() % 5];
S[i].year_of_made = 2010 + rand () % 11;
S[i].cost = 1 + rand() % 100;
S[i].weight = 100 + rand() + 301;
cout << setw(15) << S[i].type << setw(15) << S[i].name << setw(15) << S[i].colour << setw(15) << S[i].place_of_made << setw(15) << S[i].shape << setw(20) << S[i].extra_facilities << setw(15) << S[i].name_of_company << setw(15) << S[i].year_of_made << setw(15) << S[i].cost << setw(15) << S[i].weight << endl;
}
cout << "\n\n" << endl;
// sichqonchalarnig narxlarini kamayish tartibida chop etrish
cout << "narxlarning kamayish tartibi bo'yicha saralanadi " << endl;
int k;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (S[i].cost < S[j].cost) {
Computer_mouses k = S[i];
S[i] = S[j];
S[j] = k;
}
}
}
for (int i = 0; i < n; i++) {
cout << setw(15) << S[i].type << setw(15) << S[i].name << setw(15) << S[i].colour << setw(15) << S[i].place_of_made << setw(15) << S[i].shape << setw(20) << S[i].extra_facilities << setw(15) << S[i].name_of_company << setw(15) << S[i].year_of_made << setw(15) << S[i].cost << setw(15) << S[i].weight << endl;
}
return 0;
}
2 – misol:
3- misol:
Do'stlaringiz bilan baham: |