“Ma’lumotlar tuzilmasi va algoritmlari” fanidan bajargan 3-amaliy ishi
Download 190.57 Kb. Pdf ko'rish
|
Hujjat (8)
Muhammad Al-Xorazmiy nomidagi Toshkent Axborot Texnologiyallari Universiteti “Kompyuter injeneringi” Fakulteti 216-guruh talabasi Qayumov Orifjonning “Ma’lumotlar tuzilmasi va algoritmlari” fanidan bajargan 3-amaliy ishi 14-variant 1-misol Ro‘yhat yarating, Ro‘yhatga N ta haqiqiy son kiriting. Ro‘yhatning barcha toq elementlarini yig’indisini ro‘yhat boshiga qo’shish dasturini tuzing. Dastur kodi: #include #include #include #include using namespace std; int main(){ srand(time(NULL)); cout<<"Nechta element kiritilsin: "; short n; cin>>n; list for (short i=0; i list1.push_back(rand()%101-50); } cout< int s=0; for (iter=list1.begin(); iter!=list1.end(); iter++) { cout<<*iter<<" "; if (*iter%2 == 1) s+=*iter; } cout< for (iter=list1.begin(); iter!=list1.end(); iter++) cout<<*iter<<" "; return 0; } 14-variant.2-misol N ta elementdan tashkil topgan dek berilgan. Dekning barcha musbat elementlarini yig’indisini toping. Dastur kodi: #include #include #include using namespace std; int main() { srand(time(NULL)); int n; cout<<"Nechta son kiritlilsin:"; cin>>n; deque for(int i=0;i int sum=0; cout<<"Deque elemetlari:"; for(int r:d) cout< if(q>0){ sum+=q; } } cout< Download 190.57 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling