Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <stdlib.h>
- using namespace std;
- bool vakacio(vector<int> x, int i)
- {
- int j = 0;
- while (j < 7 && x[i+j] == 1)
- {
- j++;
- }
- return j >= 7;
- }
- int hanynap(int n, vector<int> x)
- {
- int i = 0;
- while (!vakacio(x,i))
- {
- i++;
- }
- return i;
- }
- void beolvas(int * n, vector<int> * napok)
- {
- while (!(*n>0 || *n > 366))
- {
- cerr << "Kerem n erteket! 0-366 kozott." << endl;
- cin >> *n;
- if (cin.fail())
- {
- cerr << "Szamot varok." << endl;
- cin.clear();
- cin.ignore(256,'\n');
- }
- }
- for (int i = 0; i < *n; i++)
- {
- int tmp = -1;
- while (!(tmp == 0 || tmp == 1))
- {
- cerr << "Kerem a " << i+1 << ". erteket. 1 vagy 0." << endl;
- cin >> tmp;
- if (cin.fail())
- {
- cerr << "Szamot varok." << endl;
- cin.clear();
- cin.ignore(256,'\n');
- }
- }
- (*napok).push_back(tmp);
- }
- bool letezikvakacio = false;
- for (int i = 1; i < (*n) - 6 && !letezikvakacio; i++)
- {
- if (vakacio(*napok,i-1))
- {
- letezikvakacio = true;
- }
- }
- if (!letezikvakacio)
- {
- cerr << "nincs tobb vakacio" << endl;
- exit(1);
- }
- }
- int main()
- {
- vector<int> napok;
- int n = 0;
- beolvas(&n,&napok);
- int db = hanynap(n,napok);
- cout << "Meg " << db << " napot kell aludni a kovetkezo vakacioig." << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement