Guest User

Unt13

a guest
Jan 15th, 2020
88
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int max_element(int **&A,int N){
  5. int max = A[0][0]
  6. for(int i = 0; i<N; ++i){
  7. for(int j = 0; j<N; ++j){
  8. if(A[i][j]>max){
  9. max = A[i][j];
  10. }
  11. }
  12. return max;
  13. }
  14.  
  15. void perebor(int**&A,int N){
  16. for(int i = 0; i<N;++i){
  17. C[N] = A[i][i];
  18. }
  19. for(bool f = true;f;){
  20. f = false;
  21. for(int i =0; i<N; ++i ){
  22. if (A[i] > A[i+1]){
  23. int tmp = A[i];
  24. A[i] = A[i+1];
  25. A[i+1] A[i];
  26. f = true;
  27. }
  28.  
  29. }
  30.  
  31. }
  32.  
  33. int main(){
  34. int N,M;
  35. cin>>N;
  36. int**A;
  37. A = new int*[N];
  38. for(int i = 0; i<N; ++i ){
  39. A[i] = new int*[N];
  40. }
  41. for(int i = 0; i<N; ++i){
  42. for(int j = 0; j<N; ++j){
  43. cin>>A[i][j];
  44. }
  45. cin>>M;
  46. int**B;
  47. B = new int*[M];
  48. for(int i =0;i<M;++i){
  49. B[i] = new int*[M];
  50. }
  51. for(int i =0; i<M;++i)
  52. {
  53. for(int j = 0; j<M;++j){
  54. cin>>B[i][j];
  55. }
  56. }
  57. maxA = max_element(A,N);
  58. maxB = max_element(B,N);
  59. if(maxA>maxB){
  60. perebor(A,N);}
  61.  
  62. else
  63. {
  64. perebor(B,M);
  65. }
  66.  
  67. }
  68. }
RAW Paste Data