|
O‘zbekiston respublikasi raqamli texnologiyalar vazirligi muhammad al-xorazmiy nomidagi toshkent axborot
|
bet | 2/2 | Sana | 19.12.2023 | Hajmi | 0,64 Mb. | | #124219 |
Bog'liq mta mustaqil ishKod:
#include
using namespace std;
class Node{
public: int number;
Node* next;
};
int main()
{ Node* head = NULL;
Node* lastPtr = NULL;
short action = -1;
while (1)
{ cout<<"1. element qushish\n";
cout<<"2. Ro'yhatni ko'rish\n";
cout<<"3. musbatlar yig'indisini ro'yhat oxiriga qo'shish\n";
cout<<"0. chiqish\n\n";
cout<<"tanlang: ";
cin>>action;
if (action == 0) {
system("CLS");
break;}
if (action == 1)
{ system("CLS");
Node* ptr = new Node;
int numb = -1;
cout<<"son kiriting: ";
cin>>numb;
ptr->number = numb;
ptr->next = NULL;
if (head == 0)
{ head = ptr;
lastPtr = ptr;
system("CLS");
continue;
}
lastPtr->next = ptr;
lastPtr = ptr;
system("CLS");
continue;
}
if (action == 2){
Node* ptr = NULL;
system("CLS");
if (head == 0)
{ cout<<"\t!!! ro’yhat bo’sh !!!\n\n";
system("PAUSE");
system("CLS");
continue;
}
cout<<"* * * * * ro’yhat * * * * *\n\n";
ptr = head;
while (1) {
cout<
number<<" ";
if (ptr->next == 0) break;
ptr = ptr->next;
}
cout<<"\n\n";
system("PAUSE");
system("CLS");
continue;
}
if (action == 3)
{
system("CLS");
Node* p = head;
Node* q = new Node;
Node* last = new Node;
int max=p->number; q=head;
int count = 0;
while(p){
if(0
number){ count += p->number;}
p=p->next;
}
system("CLS");
Node* ptr = new Node;
int numb = count;
ptr->number = numb;
ptr->next = NULL;
if (head == 0)
{ head = ptr;
lastPtr = ptr;
system("CLS");
continue;
}
lastPtr->next = ptr;
lastPtr = ptr;
cout<<"Barcha musbat elementlar yig'indisi ro'yhat oxiriga qo'shildi "<
system("pause");
continue;
}
}}
Natija:
Xulosa:
Bir bog’lamli ro’yxatlar ustida amallar va algoritmlar mavzusida mustaqil ish tayyorlandi.tayyorlanish davomida bag’langan ro’yxatlar mavzusi to’liq o’zlashtirildi.Bog’langan ro’yxatlar chiziqli ro’yxatlar va bir bog’lamli va ikki bog’lamli royxatlar haqida malumotlar izlandi topildi va tayyorlanga mustaqil ishga joylandi.Mavzu yuzasidan nazariy va amaliy malumotlarga ega bo’lindi.
Foydalanilgan adabyotlar:
1.fayllar.org.
2.arxiv.uz.
3.lms saytidagi maruza mashg’ulotidagi manbalar.
4.kompy.info.
|
| |