Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- int A, PomA, sumaA = 0; //inty do A
- int B, PomB, sumaB = 0; //inty do B
- cout<<"Podaj liczbe A: "; cin>>A; //Podanie liczby A
- if(A < 1)//Zabezpieczenie
- {
- cout<<"Blad!"<<endl;
- return 0;
- }
- PomA = A;
- cout<<"Dzielniki liczby A: ";
- for(int i = 2; i <= A; i++)
- {
- if(PomA%i == 0)
- {
- PomA /= i;
- sumaA = sumaA + PomA;
- cout<<PomA<<" ";
- }
- PomA = A;
- }
- cout<<endl;
- cout<<"Suma dzielnikow A to: "<<sumaA<<" lub tez: "<<sumaA-1<<"+1"<<endl;
- cout<<endl;
- cout<<"Podaj liczbe B: "; cin>>B; //Podanie liczby B
- if(B < 1)//Zabezpieczenie
- {
- cout<<"Blad!"<<endl;
- return 0;
- }
- PomB = B;
- cout<<"Dzielniki liczby B: ";
- for(int i = 2; i <= B; i++)
- {
- if(PomB%i == 0)
- {
- PomB /= i;
- sumaB = sumaB + PomB;
- cout<<PomB<<" ";
- }
- PomB = B;
- }
- cout<<endl;
- cout<<"Suma dzielnikow B to: "<<sumaB<<" lub tez: "<<sumaB-1<<"+1"<<endl;
- cout<<endl;
- cout<<endl;
- cout<<"Podsumowanie: "<<endl;
- cout<<"Liczba A: "<<A<<" do sumy dzielnikow B: "<<sumaB<<" lub "<<sumaB-1<<"+1"<<endl;
- cout<<"Liczba B: "<<B<<" do sumy dzielnikow A: "<<sumaA<<" lub "<<sumaA-1<<"+1"<<endl;
- cout<<endl;
- cout<<endl;
- cout<<"Odpowiedz:"<<endl;
- if((sumaB-1 == A) && (sumaA-1 == B))
- {
- cout<<"Liczby sa skojarzone!"<<endl;
- }
- else
- {
- cout<<"Liczby nie sa skojarzone"<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement