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;
}
Do'stlaringiz bilan baham: |