Laboratoriya 3
Tekshirdi: Mirzayeva G
Bajardi: Husenov D
12 – variant
#include
#include
#include
using namespace std;
int main(){
set toplam;
int n;
cout << "n = "; cin >> n;
string satr;
for(int i = 0; i < n; i++){
cout << i+1 << "-elementni kiriting : ";
cin >> satr;
toplam.insert(satr);
}
cout << "TO'PLAM :";
for(auto it : toplam)
cout << " " << it;
int kichik = 0, katta = 0;
for(auto it : toplam)
if(isupper(it[0]))
katta++;
else
if(islower(it[0]))
kichik++;
cout << "\nKatta harf bilan boshlanadagidan elementlari soni : " << katta;
cout << "\nKichik harf bilan boshlanadagidan elementlari soni : " << kichik;
return 0;
}
#include
#include
#include
using namespace std;
class OPT {
public:
string nomi, turi;
int yili, razryad, imkon;
};
void in(OPT a[], int n) {
cout << "Operatsion tizim nomi : ";
cin.ignore();
getline(cin,a[n].nomi);
cout << "Yili : ";
cin >> a[n].yili;
cout << "razryad : ";
cin >> a[n].razryad;
cin.ignore();
cout << "turi : ";
getline(cin,a[n].turi);
cout << "imkoniyatlar soni : ";
cin >> a[n].imkon;
}
void toplam_1(OPT info[], int n,multimap&bir) {
int k = 0;
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
if (info[i].nomi == info[j].nomi) {
bir.insert(pair(info[i].nomi, k++));
}
}
}
}
void toplam_2(OPT info[],int n, multimap&ikki) {
int k = 0;
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
if (info[i].yili == info[j].yili) {
ikki.insert(pair(info[i].yili, k++));
}
}
}
}
void toplam_3(OPT info[], int n, multimap& uch) {
int k = 0;
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
if (info[i].razryad == info[j].razryad) {
uch.insert(pair(info[i].razryad, k++));
}
}
}
}
void toplam_4(OPT info[], int n, multimap& tort) {
int k = 0;
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
if (info[i].turi == info[j].turi) {
tort.insert(pair(info[i].turi, k++));
}
}
}
}
void toplam_5(OPT info[], int n, multimap& besh) {
int k = 0;
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
if (info[i].imkon == info[j].imkon) {
besh.insert(pair(info[i].imkon, k++));
}
}
}
}
template
void out(T ekran) {
for (auto x : ekran) {
cout << x.first << endl;
}
}
int main() {
multimap bir, tort;
multimap ikki, uch, besh;
cout << "nechta ma'lumot kiritmoqchisiz : ";
int n;
cin >> n;
OPT info[15];
for (int i = 0; i < n; i++) {
cout << i + 1 << "- ma'lumot :\n\n ";
in(info, i);
}int x;
g:
cout << "Ma'lumotlarni ko'rish uchun toplam sonini kiriting : ";
cin >> x;
switch (x) {
case 0: cout << "Dastur tugatildi.";
break;
case 1:
toplam_1(info, n, bir);
out(bir);
break;
case 2:
toplam_2(info, n, ikki);
out(ikki);
break;
case 3:
toplam_3(info, n, uch);
out(uch);
break;
case 4:
toplam_4(info, n, tort);
out(tort);
break;
case 5:
toplam_5(info, n, besh);
out(besh);
break;
default:
cout << "Siz mavjud bo'lmagan son kiritdingiz.\nP.S: 1-nomi\t2-yili\t3-razryadi";
cout<<"\t4 - Turi\t5 -Imkoniyatlar soni\n0-exit\n";
goto g;
}
return 0;
}
Dostları ilə paylaş: |