Misol: Dekning juft elementlari yig`indisini hisoblang


Download 29.01 Kb.
Sana18.03.2023
Hajmi29.01 Kb.
#1283341
Bog'liq
Kenjaboyev Hamdambek 943 21 10-amaliyot 4 topshiriq


10-amaliyot
Misol: Dekning juft elementlari yig`indisini hisoblang

#include


#include
#include
#include
using namespace std;
int main()
{
srand(time(0));
int n;
cout << "\n Dekning o'lchamini kiriting: ";
cin >> n;
deque dek;
cout << "\n Dekning dastlabki elementlari:\n\n[";
for (int i = 0; i < n; i++)
{
dek.push_back(rand() % 100 + 1);
cout << dek[i] << ", ";
}
cout << "\b\b]\n\n";
int sum = 0;
for (auto &&i : dek)
{
if (i % 2 == 0)
sum += i;
}
cout << "\n Dekning juft elemenetlari yig'indisi: " << sum << endl;
cout << endl;
system("pause");
return 0;
}



Download 29.01 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling