|
Allakuliyev Abdusharip 42-22 guruh 3-amaliyot 1-topshiriq dasturlash masala
|
tarix | 19.06.2023 | ölçüsü | 255,51 Kb. | | #132646 |
| 3-amaliyot Allakuliyev Abdusharip
Allakuliyev Abdusharip
942-22 guruh
3-amaliyot
1-topshiriq
DASTURLASH 2
MASALA :
__________________________________________________________________
Topshiriqlar.
Array konteyner sinfi berilgan . Uni barcha elementlarini bir hil son bilan to’ldiring.
DASTUR KODI :
#include
#include
using namespace std;
int main() {
deque dq;
// barcha elementlarni 1 ga o'zgartirish
for(int i = 0; i < 10; i++) {
dq.push_back(1);
}
// deque dagi barcha elementlarni chiqarish
for(int i = 0; i < dq.size(); i++) {
cout << dq[i] << " ";
}
return 0;
}
DASTUR NATIJASI :
1 1 1 1 1 1 1 1 1 1 __________________________________________________________________
Allakuliyev Abdusharip
942-22 guruh
3-amaliyot
2-topshiriq
DASTURLASH 2
MASALA :
__________________________________________________________________
Bir tomonlama ro’yxat (forward_list) berilgan. Ro’yxat elementlari yig’indisini toping.
DASTUR KODI :
#include
#include
using namespace std;
void print(forward_list d){
cout<<"Ro'yxat el.lari: ";
while(!d.empty()){
cout<
d.pop_front();
}
cout<
}
void f1(forward_list d){
cout<<"List sum: "<
int s=0;
while (!d.empty()){
s+=d.front();
d.pop_front();
}
cout<
}
int main(){
forward_list d ;
for (int i=1; i<=10 ; i++){
d.push_front (i*i);
}
print (d);
f1(d);
}
DASTUR NATIJASI :
Ro'yxat el.lari: 100 81 64 49 36 25 16 9 4 1
List sum:
Dostları ilə paylaş: |
|
|