3-AMALIYOT ISHI
MAVZU:STACK,QUEUE,DEQUEUE(STEK,NAVBAT,DEK)
VARIANT-14
14. N ta elementdan tashkil topgan dek berilgan. Dekning barcha musbat elementlarini yig’indisini toping.
DASTUR KODI
#include
using namespace std;
int main() {
int N;
cout << "Dekning o'lchamini kiriting: ";
cin >> N;
int dek[N];
cout << "Dekni yaratish: ";
for (int i = 0; i < N; ++i) {
cin >> dek[i];
}
int positiveSum = 0;
for (int i = 0; i < N; ++i) {
if (dek[i] > 0) {
positiveSum += dek[i];
}
}
cout << "Dekning barcha musbat elementlarining yig'indisi: " << positiveSum << endl;
return 0;
}
NATIJA
Bajardi: Nuriddinov Boburbek
Do'stlaringiz bilan baham: |