Facebook
From Putrid Cassowary, 3 Years ago, written in Plain Text.
This paste is a reply to Untitled from Commodious Terrapin - view diff
Embed
Download Paste or View Raw
Hits: 84
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct nwda{
  5.         int a, b, nwd;
  6. };
  7. void a(){
  8.         nwda a1;
  9.         cout<<"Podaj liczbe a: ";
  10.         cin>>a1.a;
  11.         cout<<"Podaj liczbe b: ";
  12.         cin>>a1.b;
  13.        
  14.         while(a1.a!=a1.b)
  15.        if(a1.a>a1.b)
  16.            a1.a-=a1.b;
  17.        else
  18.            a1.b-=a1.a;
  19.     a1.nwd = a1.a;
  20.     cout<<"NWD = "<<a1.nwd<<endl;
  21. }
  22.  
  23. struct nwdb{
  24.         int a, b, nwd;
  25.         void ab();
  26. };
  27. void nwdb::ab(){
  28.         cout<<"Podaj liczbe a: ";
  29.         cin>>a;
  30.         cout<<"Podaj liczbe b: ";
  31.         cin>>b;
  32.        
  33.         while(a!=b)
  34.        if(a>b)
  35.            a-=b;
  36.        else
  37.            b-=a;
  38.     nwd = a;
  39.     cout<<"NWD = "<<nwd<<endl;
  40. }
  41.  
  42. int main() {
  43.         a();
  44.         system("pause");
  45.         nwdb b1;
  46.         b1.ab();
  47.         system("pause");
  48. }