• 2-AMALIYOT ISHI BAJARDI:HAYDAROV HAYOTJON TEKSHIRDI:DJANGAZOVA.K TOSHKENT—2022 9-VARIANT
  • Kodi: include using namespace std; int main() { int x,a,b,c; cout >x;
  • include include include using namespace std; void printArray(int arr[], int n){
  • NATIJA 4.N ta elementdan tashkil topgan stek berilgan. stekning o’rtadagi elemntini o’chiring. DASTUR KODI
  • Muhammad al-xorazmiy nomidagi toshkent axborot texnologiyalari universiteti kompyuter injiniringi fakulteti malumotlar tuzilmasi va algoritmlash fani bo




    Download 1.07 Mb.
    Sana29.01.2023
    Hajmi1.07 Mb.
    #40062
    Bog'liq
    2-amaliy ish
    1000 ta eng kerakli fe llar lug ati. (@Ruschani orgatamiz), to`g`ri chiziq tinglamalari00, IAKTT MUSTAQIL ISH RAYA hemisga, Славистика. Рогозинникова Н.Г., Электрон рақамли имзо, eleklab1, 1700734682, prUjqIbazCrcvdZHf5c0Jtx7zzt-j9l7, Xayitmuradova, Alixonov 2011, 1. Axborot xavfsizligiga bo‘ladigan tahdidlar. Tahdid turlari, 38-Moliyaviy-risklarni-boshqarish-Oquv-qollanma-K-Sharifxodjayeva-T2017, 1797118, Suyuqlik va sochiluvchan moddalarning sathini o\'lchash Rеjа-fayllar.org

    O’ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI


    MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
    KOMPYUTER INJINIRINGI FAKULTETI
    MALUMOTLAR TUZILMASI VA ALGORITMLASH FANI BO’YICHA YOZGAN
    2-AMALIYOT ISHI
    BAJARDI:HAYDAROV HAYOTJON
    TEKSHIRDI:DJANGAZOVA.K

    TOSHKENT—2022

    9-VARIANT

    1. Uch xonali raqam berilgan. Yuzlik raqamni o’nlik raqam bilan almashtirganda paydo bo’lgan raqamni chiqaring.



    Kodi:
    #include
    using namespace std;
    int main()
    {
    int x,a,b,c;
    cout<<"Son kiriting:";cin>>x;
    a=x/100;
    b=(x%100)/10;
    c=(x%100)%10;
    cout<<"Yuzlik raqamni o'nlik raqam bilan almashtirgandan keyin \n";
    cout<<"Natija:"<
    return main();
    }
    DASTUR NATIJASI:



    2.Toq va juft sonlardan tashkil topgan B massiv berilgan. Barcha toq sonlarni chiqarib, juft sonlarini To’g’ridan-to’g’ri qo’shish usuli bilan saralash algoritmidan foydalanib o’sish tartibda joylashtiruvchi dastur tuzing.

    #include
    #include
    #include

    using namespace std;

    void printArray(int arr[], int n){
    for(int i = 0; i < n; i++)
    cout << arr[i] << " ";
    cout << endl << endl;
    }

    void delElement(int arr[], int index, int n){
    for(int i = index; i < n-1; i++)
    arr[i] = arr[i+1];
    }

    int main(){
    srand(time(0));
    int n;
    cout << "n = "; cin >> n;
    int B[n];
    // random sonlar [0, 10) oraliqda
    for(int i = 0; i < n; i++){
    B[i] = rand() % 10;
    }
    cout << endl << "B[" << n << "] sonlar ro'yxati:" << endl;
    printArray(B, n);
    // toq sonlarni o'chirib tashlash
    for(int i = 0; i < n; i++){
    if(B[i] % 2 != 0){
    delElement(B, i, n);
    i--; n--;
    }
    }
    cout << "Toq elementlari o'chirib tashlangach:" << endl;
    printArray(B, n);
    // insertion sort
    int i, j, k;
    for (i = 1; i < n; i++){
    j = i - 1;
    k = B[i];
    while (j >= 0 && B[j] > k){
    B[j + 1] = B[j];
    j--;
    }
    B[j + 1] = k;
    }
    cout << "Sort qilingach:" << endl;
    printArray(B, n);
    return main();
    }

    Dastur natijasi:


    3. Ro’yhat yarating, Ro’yhatga N ta haqiqiy son kiriting. Ro’yhatning 6 dan kichkina barcha elementlari yig’indisini ro’yhat oxiriga qo’shish dasturini tuzing.
    DASTUR KODI
    #include
    #include
    #include
    using namespace std;

    class Node{


    public:
    int value;
    Node *next;
    };

    void push(Node** head, int val){


    Node* new_node = new Node();
    new_node->value = val;
    new_node->next = (*head);
    (*head) = new_node;
    }

    void printList(Node *node){


    while (node != NULL){
    cout << node->value << " ";
    node = node->next;
    }
    cout << endl;
    }

    int main(){


    srand(time(0));
    Node* head = NULL;
    int N; cout << "N = "; cin >> N;
    for(int i = 0; i < N; i++){
    push(&head, rand() % 10);
    }
    cout << "Linked list: ";
    printList(head);
    int s = 0;
    Node* node = head;
    while (node->next != NULL){
    if(node->value < 6) s += node->value;
    node = node->next;
    }
    Node* new_node = new Node();
    new_node->value = s;
    node->next = new_node;
    cout << "6 dan kichik elementlari yig'indisi: " << s << endl;
    cout << "Linked List: ";
    printList(head);
    return 0;
    }

    NATIJA
    4.N ta elementdan tashkil topgan stek berilgan. stekning o’rtadagi elemntini o’chiring.
    DASTUR KODI
    #include
    #include
    #include
    #include
    using namespace std;

    void printStack(stack s){


    while(!s.empty()){
    cout << s.top() << " ";
    s.pop();
    }
    cout << endl;
    }

    int main(){


    srand(time(0));
    stack s;
    int N;
    cout << "N = "; cin >> N;
    for(int i=0; is.push(rand() % 20);
    }
    printStack(s);
    stack s2;
    for(int i=0; is2.push(s.top());
    s.pop();
    }
    if(N % 2 == 0){
    cout << "O'rtadagi elementlari: " << s.top() << " ";
    s.pop();
    cout << s.top() << endl;
    s.pop();
    }
    else{

    s2.push(s.top());


    s.pop(); // o'rtaga yetib kelgach 1 ta keyingisiga o'tish
    cout << "O'rtadagi elementi: " << s.top() << endl;
    s.pop(); // o'rtadagisi
    }
    while(!s2.empty()){
    s.push(s2.top());
    s2.pop();
    }
    cout << "O'rtadagi elementi o'chirilgach: " << endl;
    printStack(s);
    return 0;
    }

    N ATIJA
    Agar N juft son bo’lsa o’rtasidagi 2 ta elementni o’chiradi.

    Agar N toq son bo’lsa bunda teng o’rtasida bittagina element bo’ladi va o’shani o’chiradi.

    Download 1.07 Mb.




    Download 1.07 Mb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Muhammad al-xorazmiy nomidagi toshkent axborot texnologiyalari universiteti kompyuter injiniringi fakulteti malumotlar tuzilmasi va algoritmlash fani bo

    Download 1.07 Mb.