Advertisement
Lisaveta777

?

Nov 1st, 2018
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.03 KB | None | 0 0
  1. #include <stdio.h>  //??? Swap() doesn; change values in main! Fix it!!! Call by //reference and so on
  2. //plus – I want to print every 3 unique combinations just once, not 6 times!
  3. #define SIZE 50
  4. void swap_abc(int,int,int);
  5.  
  6. int main()
  7. {
  8.     int a,b,c,arr[SIZE][SIZE];
  9.     for(a=1;a<SIZE;a++)
  10.     {
  11.         for(b=1;b<SIZE;b++)
  12.         {
  13.             for(c=1;c<SIZE;c++)
  14.             {
  15.                 if((a*a==b*b+c*c)||(c*c==a*a+b*b)||(b*b==a*a+c*c))
  16.                    {
  17.                        printf("%d %d %d\t",a,b,c);
  18.                        swap_abc(a,b,c);
  19.                        printf("%d %d %d\n",a,b,c);
  20.  
  21.                    }
  22.             }
  23.         }
  24.     }
  25.  
  26.     return 0;
  27. }
  28. void swap_abc(int aa,int bb,int cc)
  29. {
  30.     int temp;
  31.     while((aa>bb)||(bb>cc)||(aa>cc))
  32.     {
  33.         if(aa>bb)
  34.         {
  35.             temp=aa;aa=bb;bb=temp;
  36.         }
  37.         if(bb>cc)
  38.         {
  39.             temp=bb;bb=cc;cc=temp;
  40.         }
  41.         if(aa>cc)
  42.         {
  43.             temp=aa;aa=cc;cc=temp;
  44.         }
  45.     }
  46.      }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement