Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- using namespace std;
- int main()
- {
- int x,y;
- cout << "Podaj 2 liczby: " << endl;
- cin >> x >> y;
- if (x<0)
- {
- x=x*-1;
- }
- if (y<0)
- {
- y=y*-1;
- }
- if (x>y)
- {
- cout << "Wieksza wartosc bezwzgledna ma pierwsza liczba: " << x;
- }
- else if (x<y)
- {
- cout << "Wieksza wartosc bezwzgledna ma druga liczba: " << y;
- }
- else
- {
- cout << "Wartosci bezwzgledne obu liczb sa takie same";
- }
- /*
- alternatywne rozwiazanie
- x = abs(x); //bezwzgledna x
- y = abs(y); //bezwzgledna y
- if (x>y)
- {
- cout << "Wieksza wartosc bezwzgledna ma liczba x: " << x;
- }
- else
- {
- cout << "Wieksza wartosc bezwzgledna ma liczba y: " << y;
- }
- */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement