Created
September 27, 2016 07:48
-
-
Save horvathgyozo/a5fbcd4d80077f942398863c9b26455c to your computer and use it in GitHub Desktop.
Progalap: védett falak (példa megoldás)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
void beolvas(vector<bool> &orhelyek) | |
{ | |
int n; | |
cin >> n; | |
orhelyek.resize(n); | |
for (int i = 0; i < n; i++) | |
{ | |
int sv; | |
cin >> sv; | |
orhelyek[i] = sv; | |
} | |
} | |
int vedett_falak_szama(const vector<bool> orhelyek) | |
{ | |
int db = 0; | |
int n = orhelyek.size(); | |
for (int i = 0; i < n - 1; i++) | |
{ | |
if (orhelyek[i] && orhelyek[i + 1]) | |
{ | |
db += 1; | |
} | |
} | |
return db; | |
} | |
void kiir(const int db) | |
{ | |
cout << db << endl; | |
} | |
int main() | |
{ | |
vector<bool> orhelyek; | |
int db; | |
beolvas(orhelyek); | |
db = vedett_falak_szama(orhelyek); | |
kiir(db); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment