Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int NWD (int a, int b)
- {
- int c;
- while (b != 0)
- {
- c = a % b;
- a = b;
- b = c;
- }
- return a;
- }
- /////////////////////////
- int main()
- {
- int size=0,nwd[4],temp=0;
- cin>>size;
- while(size>0){
- int tab[4];
- for (int i=0; i<4; i++) cin>>tab[i];
- nwd[0]=NWD(tab[0],tab[1]);
- temp=nwd[0];
- for (int m=0; m<3; m++)
- {
- temp=NWD(nwd[m],tab[m+1]);
- nwd[m+1]=temp;
- }
- cout << temp<< endl;
- temp=0;
- nwd[0]=0;
- tab[0]=0;
- --size;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement