Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // jedynki.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- bool funkcja(int tab[], int n)
- {
- int jedynki = 0;
- for (int i = 0; i < n; i++)
- {
- if (tab[i] == 1)jedynki++;
- }
- for (int i = 0; i < n; i++)
- {
- if (tab[i] == 1)
- {
- for (int j = 0; j < jedynki; j++)
- {
- if (tab[i + j] != 1)return false;
- }
- return true;
- }
- }
- return false;
- }
- int main()
- {
- srand(time(NULL));
- int n;
- cin >> n;
- int *tab = new int[n];
- for (int i = 0; i < n; i++)
- tab[i] = rand()%2;
- for (int i = 0; i < n; i++)
- cout << tab[i];
- if (funkcja(tab, n))cout << "Prawda" << endl;
- else cout << "Nieprawda" << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment