Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Massivler
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- cin >> n; // massivin olcusu
- int a[n + 5]; // massivde n + 5 element var [0 , n + 4]
- // + 1 de yazilar, amma bezen n + 1 , n + 2 , n + 3 , n + 4 lazim ola biler
- for(int i = 0; i < n; i++){ // [0 , n) --> [0 , n - 1] --> nomreleme 0 dan baslayir
- cin >> a[i]; // a massivinin i ci elementi a[i]
- }
- //demeli a[0] birinci , a[n - 1] ise sonuncu elementidi
- // eger meselede musbet ededlerin sayi dese
- int cnt_positive = 0; // deyisen adini istenilen uygun ad qoya bilersen
- for(int i = 0; i < n; i++){ // butun massive baxiriq
- if(a[i] > 0) // eger i ci element 0 dan boyukse (musbetse)
- cnt_positive++; // 1 vahid artir saygaci
- }
- cout << cnt_positive << endl;
- //eger meselede tek ededleri cixisa ver dese
- for(int i = 0; i < n; i++){ // yene butun massive baxiriq
- if(a[i] % 2) // eger 2 ye qaligi 0 deyilse (varsa)
- cout << a[i] << " ";
- }
- cout << endl;
- // massivi tersine cixisa ver
- for(int i = (n - 1); i >= 0; i--){ // hardan baslayiriq (n - 1) den sonuncu elementden hara qeder 0 (birinci element) i-- (sol terefe gedirik)
- cout << a[i] << " ";
- }
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement