fork(1) download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int main()
  5. {
  6. double max = 0;
  7. int K=2,L,x=0,y=1;
  8. cin >> L;
  9. int D[K][L];
  10. for (int i = 0; i < K; i++)
  11. {
  12. for (int j = 0; j < L; j++)
  13. {
  14. cin>>D[i][j];
  15. }
  16. }
  17. for (int i = 0; i < L-1; i++)
  18. {
  19. for (int j = 0; j < L; j++)
  20. {
  21. double q=sqrt((D[x][i]-D[x][j])*(D[x][i]-D[x][j])+(D[y][i]-D[y][j])*(D[y][i]-D[y][j]));
  22. if(q>max)
  23. {
  24. max=q;
  25. }
  26. }
  27. }
  28. for (int i = 0; i < K; i++)
  29. {
  30. for (int j = 0; j < L; j++)
  31. {
  32. cout<<D[i][j]<<" ";
  33. }
  34. cout<<"\n";
  35. }
  36. cout<<max;
  37. return 0;
  38. }
Success #stdin #stdout 0s 3460KB
stdin
4
6
14
2
1
9
3
8
0
stdout
6 14 2 1 
9 3 8 0 
13.3417