skonczone ez
This commit is contained in:
parent
99dfe06daf
commit
35be87a5b2
@ -1,24 +1,54 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
int ip = 3, podzielniki[ip];
|
{
|
||||||
|
int a, b, n;
|
||||||
|
|
||||||
//podaj podzielniki
|
cout << "Przedzial od ";
|
||||||
cout << "Podaj " << ip << " podzielniki: ";
|
cin >> a;
|
||||||
for (int i = 0; i < ip; i++) {
|
cout << "Do ";
|
||||||
|
cin >> b;
|
||||||
|
|
||||||
|
cout << "Ilosc podzielnikow: ";
|
||||||
|
cin >> n;
|
||||||
|
|
||||||
|
if (n <= 0) {
|
||||||
|
cout << "Liczba podzielnikow musi byc wieksza od zera!" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int podzielniki[100];
|
||||||
|
cout << "Podaj " << n << " podzielniki: ";
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
cin >> podzielniki[i];
|
cin >> podzielniki[i];
|
||||||
|
if (podzielniki[i] == 0) {
|
||||||
|
cout << "Podzielnik nie moze byc zerem!" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//wyswietl podzielniki
|
int tablica[100], index = 0;
|
||||||
cout << "Podzielniki: ";
|
for (int i = a; i <= b; i++) {
|
||||||
for (int i = 0; i < ip; i++) {
|
int podzielny = 1;
|
||||||
cout << podzielniki[i] << " ";
|
for (int j = 0; j < n; j++) {
|
||||||
|
podzielny *= (i % podzielniki[j] == 0);
|
||||||
|
}
|
||||||
|
if (podzielny) {
|
||||||
|
tablica[index++] = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cout << endl;
|
|
||||||
|
|
||||||
//podaj przedzial
|
|
||||||
|
|
||||||
|
if (index == 0) {
|
||||||
|
cout << "Brak liczb podzielnych przez wszystkie podane podzielniki w podanym przedziale." << endl;
|
||||||
|
} else {
|
||||||
|
cout << "Liczby podzielne przez wszystkie podane podzielniki w przedziale " << a << " - " << b << ": ";
|
||||||
|
for (int i = 0; i < index; i++) {
|
||||||
|
cout << tablica[i] << " ";
|
||||||
|
}
|
||||||
|
cout << endl;
|
||||||
|
}
|
||||||
|
|
||||||
system("pause");
|
system("pause");
|
||||||
return 0;
|
return 0;
|
||||||
|
BIN
tablica/main.exe
BIN
tablica/main.exe
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user