• Islomov Umidjon
  • Islomov Umidjon Tekshirdi: Ibragimova Kamila 10-variant 1-topshiriq 10. Matnli faylda n ta talabaning familiyasi, ismi va oilaviy ahvoli yozilgan. Ushbu ma'lumotlarni to'plamga o' zlashtirib




    Download 0,7 Mb.
    Sana16.05.2024
    Hajmi0,7 Mb.
    #237394
    Bog'liq
    Islomov Umidjon Dasturlash2dan 4-amaliy mashg\'ulot


    MUHAMMAD AL-XORAZMIY
    NOMIDAGI
    TOSHKENT AXBOROT
    TEXNOLOGIYALARI UNIVERSITETI

    Infokommunikatsiya injiniringgi
    1-bosqich 432-22-guruh talabasi

    Islomov Umidjonning


    Dasturlash I fanidan bajargan mustaqil ishi
    Bajardi: Islomov Umidjon
    Tekshirdi:  Ibragimova Kamila
    10-variant
    1-topshiriq

    10.Matnli faylda N ta talabaning familiyasi, ismi va oilaviy ahvoli yozilgan. Ushbu ma'lumotlarni to'plamga o' zlashtirib, turmushga chiqqanlarni aniqlaydigan dastur tuzing.

    Dastur qismi;


    #include
    #include
    #include
    using namespace std;
    class Student {
    public:
    Student(string surname, string name, bool married) : surname(surname), name(name), married(married) {}
    bool isMarried() const { return married; }
    private:
    string surname;
    string name;
    bool married;
    };
    int main() {
    const string filename = "students.txt";
    ifstream file(filename);
    if (!file) {
    cerr << "Failed to open file: " << filename << endl;
    return 1;
    }
    string surname, name, married_str;
    int n = 0;
    while (file >> surname >> name >> married_str) {
    bool married = (married_str == "Married");
    Student student(surname, name, married);
    if (student.isMarried()) {
    cout <}
    n++;
    }
    cout << "Processed " << n << " students.\n\n";
    return 0;
    }


    2-topshiriq

    10.N ta complex son berilgan. Ulaming real qismlari tasodifiy sonlar bilan, mavhum qismlari 1 dan N gacha sonlar bilan to'ldirilsin hamda ushbu N ta complex sonlarni va ularning mavhum qismlarida takrorlangan sonlarni va ularning soni ekranga chiqarilsin.

    Dastur qismi;


    2.#include
    #include
    #include
    #include
    #include
    using namespace std;
    int main() {
    srand(time(0));
    int N ;
    cout<<"N = ";cin>>N;
    vector> complexNumbers(N);
    unordered_map countMap;
    random_device rd;
    mt19937 gen(rd());
    uniform_real_distribution<> dis(0, 10);
    for (int i = 0; i < N; i++) {
    int real = dis(gen);
    int imag = rand()%N+1;
    complexNumbers[i] = complex(real, imag);

    if (countMap.find(imag) == countMap.end()) {


    countMap[imag] = 1;
    } else {
    countMap[imag]++;
    }
    }
    for (int i = 0; i < N; i++) {
    cout <<"z"<<(i+1)<<" = "<< complexNumbers[i].real() << " + " << complexNumbers[i].imag() << "i" << endl;
    }
    cout << "Repeated numbers: " << endl;
    for (auto& pair : countMap) {
    if (pair.second > 1) {
    cout << pair.first << "i - Count: " << pair.second << endl;
    }
    }
    cout<<"\n\n";
    return 0;
    }

    3-topshiriq





    Dastur qismi;
    3.#include
    #include
    #include
    #include
    #include
    using namespace std;
    int main()
    {
    srand(time(0));
    cout << "Masala shartidan tanlang:"
    << "\n 1 => Complex sinfidan foydalanib, ikkita kompleks sonlarni bo’ling.\n"
    << "2 => Slice sinfidan foydalanib valarray massiv elementlari har 10 qadamdagilarni aniqlang.\n"
    << "3 => gslice sinfidan foydalanib valarray massiv elementlarini 0 indexdan boshlab (2,5) qiymatlar sonida (10,10) qadamdagilar farqi bilan 10 ga to’ldiring: ";
    string command;
    cin >> command;
    if (command == "1")
    {
    int a, b, c, d;
    cout << " Birinchi compleks son (a + b*i): \n";
    cout << " a = ";
    cin >> a;
    cout << " b = ";
    cin >> b;
    complex top1(a, b);
    cout << top1 << endl;
    cout << " Ikkinchi compleks son (a + b*i): \n";
    cout << " c = ";
    cin >> c;
    cout << " d = ";
    cin >> d;
    complex top1_(c, d);
    cout << top1_ << endl;
    cout << " Ikkita compleks sonning bo'linmasi : ";
    cout << top1 / top1 << "\n\n";
    }
    if (command == "2")
    {
    int n;
    cout << "n = ";
    cin >> n;
    valarray v(n);
    for (int i = 0; i < n; i++)
    {
    int r = rand() % 90 + 10;
    v[i] = r;
    cout << v[i] << "\t";
    }
    cout << "\nKesib olingan valarray :\n";
    int x = n / 10;
    slice s(0, x, 10);
    valarray result = v[s];
    for (int i = 0; i < x; i++)
    {
    cout << result[i] << " ";
    }
    cout << "\n\n";
    }
    if (command == "3")
    {
    int n;
    cout << "Nechta son bo'lsin : ";
    cin >> n;
    valarray sample(n);
    for (int i = 0; i < n; ++i)
    {
    sample[i] = rand() % 98 + 1;
    cout << sample[i] << " ";
    }
    sample[gslice(0, {2, 5}, {10, 10})] = 10;
    cout << "\n\ngslice:";
    for (int i = 0; i < n; i++)
    cout << " " << sample[i];
    cout << " \n";
    }
    return main();
    }
    Natijalar;


    Download 0,7 Mb.




    Download 0,7 Mb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Islomov Umidjon Tekshirdi: Ibragimova Kamila 10-variant 1-topshiriq 10. Matnli faylda n ta talabaning familiyasi, ismi va oilaviy ahvoli yozilgan. Ushbu ma'lumotlarni to'plamga o' zlashtirib

    Download 0,7 Mb.