Advertisement
Krefeld187

Untitled

Mar 22nd, 2021
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. static int[] SundT(int a, int b, int ggt)
  2. {
  3. int arr[] = new int[2];
  4. int minSundT = 100000;
  5. int minS = 0;
  6. int minT = 0;
  7. for(int s = -10000; s < 10000; ++s)
  8. {
  9. for(int t = -10000; t < 10000; ++t)
  10. {
  11. if(s * a + t * b == ggt)
  12. {
  13. System.out.println(s + " " + t);
  14. if(Math.abs(s+t) < Math.abs(minSundT))
  15. {
  16.  
  17. minSundT = Math.abs(s + t);
  18. minS = s;
  19. minT = t;
  20. }
  21. }
  22. }
  23. }
  24. arr[0] = minS;
  25. arr[1] = minT;
  26. return arr;
  27. // System.out.println("s : " + minS + " t : " + minT + " ggT: " + ggt);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement