SHARE
TWEET

erhard me

a guest May 22nd, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <stdlib.h>
  4.  
  5. using namespace std;
  6. int A[50][50],N;
  7. void feltolt()
  8. {
  9.     srand(time(NULL));
  10.     for( int i=0;i<=N-1;i++)
  11.     {
  12.         for(int j=0;j<=N-1;j++)
  13.         {
  14.             A[i][j]=rand()%1000;
  15.         }
  16.     }
  17. }
  18. void nyomtat()
  19. {
  20.     for( int i=0;i<=N-1;i++)
  21.     {
  22.         for(int j=0;j<=N-1;j++)
  23.         {
  24.             cout.width(4);
  25.             cout<<A[i][j];
  26.         }
  27.         cout<<endl;
  28.     }
  29.     cout<<endl;
  30. }
  31. void csere(int &a, int &b)
  32. {
  33.     int s=a;
  34.     a=b;
  35.     b=s;
  36. }
  37. void rendezes()
  38. {
  39.     for( int i=0;i<=N-1;i++)
  40.         for(int j=i;j<=N-1;j++)
  41.             if(A[i][i]>A[j][j])
  42.                 csere(A[i][i],A[j][j]);
  43. }
  44. int main()
  45. {
  46.     cout<<"N=";
  47.     cin>>N;
  48.     feltolt();
  49.     nyomtat();
  50.     rendezes();
  51.     nyomtat();
  52.     return 0;
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top