Facebook
From Colorant Goose, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 214
  1. #include<iostream>
  2. #include<conio.h>
  3. using namespace std;
  4.  
  5. main(){
  6.         short x, x1, y, y1, r, r1, pomoc;
  7.         cout << "Najmniejsza wspolna wielokrotnosc" << endl;
  8.         cout << "Wprowadz dwie liczby calkowite dodatnie" << endl;
  9.         cout << "x= ";
  10.         cin >> x;
  11.         cout << "y= ";
  12.         cin >> y;
  13.         if(x>y){
  14.                 pomoc = x;
  15.                 x = y;
  16.                 y = pomoc;
  17.         }
  18.         x1 = x;
  19.         y1 = y;
  20.                 while (x1 % y1)
  21.         {
  22.                 r1 = x1 % y1;
  23.                 x1 = y1;
  24.                 y1= r1;
  25.         }
  26.        
  27.         r=x*y/(r1);
  28.        
  29.         cout << "NWW(" << x << ", " << y << ") = " << r;
  30.  
  31.  
  32.         getch();
  33. }