SHARE
TWEET

Untitled

a guest Nov 18th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <stdlib.h>
  4. using namespace std;
  5.  
  6. bool vakacio(vector<int> x, int i)
  7. {
  8.     int j = 0;
  9.     while (j < 7 && x[i+j] == 1)
  10.     {
  11.         j++;
  12.     }
  13.     return j >= 7;
  14. }
  15. int hanynap(int n, vector<int> x)
  16. {
  17.     int i = 0;
  18.     while (!vakacio(x,i))
  19.     {
  20.         i++;
  21.     }
  22.     return i;
  23. }
  24. void beolvas(int * n, vector<int> * napok)
  25. {
  26.  
  27.     while (!(*n>0 || *n > 366))
  28.     {
  29.         cerr << "Kerem n erteket! 0-366 kozott." << endl;
  30.         cin >> *n;
  31.         if (cin.fail())
  32.         {
  33.             cerr << "Szamot varok." << endl;
  34.             cin.clear();
  35.             cin.ignore(256,'\n');
  36.         }
  37.     }
  38.     for (int i = 0; i < *n; i++)
  39.     {
  40.         int tmp = -1;
  41.         while (!(tmp == 0 || tmp == 1))
  42.         {
  43.             cerr << "Kerem a " << i+1 << ". erteket. 1 vagy 0." << endl;
  44.             cin >> tmp;
  45.             if (cin.fail())
  46.             {
  47.                 cerr << "Szamot varok." << endl;
  48.                 cin.clear();
  49.                 cin.ignore(256,'\n');
  50.             }
  51.         }
  52.         (*napok).push_back(tmp);
  53.     }
  54.     bool letezikvakacio = false;
  55.     for (int i = 1; i < (*n) - 6 && !letezikvakacio; i++)
  56.     {
  57.         if (vakacio(*napok,i-1))
  58.         {
  59.             letezikvakacio = true;
  60.         }
  61.     }
  62.     if (!letezikvakacio)
  63.     {
  64.         cerr << "nincs tobb vakacio" << endl;
  65.         exit(1);
  66.     }
  67. }
  68. int main()
  69. {
  70.     vector<int> napok;
  71.     int n = 0;
  72.     beolvas(&n,&napok);
  73.     int db = hanynap(n,napok);
  74.     cout << "Meg " << db << " napot kell aludni a kovetkezo vakacioig." << endl;
  75.     return 0;
  76. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top