Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- // A12
- int a(vector<int> t)
- {
- bool flaga;
- for(int wynik = 2; true; ++wynik)
- {
- flaga = false; // zakładamy na początek, że nie ma w tablicy liczby, przez którą wynik dzieli się bez reszty
- for(unsigned i = 0; i < t.size(); ++i)
- if(wynik % t[i] == 0) // znajdujemy liczbę, przez którą wynik dzieli się bez reszty
- {
- flaga = true; // podnosimy flagę
- break;
- }
- if(!flaga) // jeżeli flaga nadal jest opuszczona, zwracamy wynik
- return wynik;
- }
- }
- int main()
- {
- vector<int> tablica;
- int liczba;
- cin >> liczba;
- while(liczba != 0)
- {
- tablica.push_back(liczba);
- cin >> liczba;
- }
- for(unsigned i = 0; i < tablica.size(); ++i)
- cout << tablica[i] << '\t';
- cout << endl;
- cout << a(tablica) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment