Advertisement
stupid_pro

Untitled

Oct 23rd, 2021
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main(){
  4. int x, y, z, t;
  5. cin >>x >>y >>z >>t;
  6. int arr[4];
  7. arr[0]=x; //a+b
  8. arr[1]=y; //b+c
  9. arr[2]=z; //a+c
  10. arr[3]=t; //a+b+c
  11. int a, b, c;
  12. int count=1;
  13. for (int i=0; i<4; i++){
  14. for (int j=0; j<6; j++){
  15. b=arr[3]-arr[2];
  16. a=arr[0]-b;
  17. c=arr[2]-a;
  18. if ((a+b+c==arr[3]) && (a+b==arr[0]) && (b+c==arr[1]) && (a+c==arr[2])) break;
  19. else {
  20. if (count%4==3) count+=2;
  21. swap (arr[count%4],arr[(count+1)%4]);
  22. }
  23. count++;
  24. }
  25. count=1;
  26. swap (arr[0], arr[1]);
  27. }
  28. cout <<a <<" " <<b << " " <<c;
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement