Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <stdlib.h>
- using namespace std;
- int A[50][50],N;
- void feltolt()
- {
- srand(time(NULL));
- for( int i=0;i<=N-1;i++)
- {
- for(int j=0;j<=N-1;j++)
- {
- A[i][j]=rand()%1000;
- }
- }
- }
- void nyomtat()
- {
- for( int i=0;i<=N-1;i++)
- {
- for(int j=0;j<=N-1;j++)
- {
- cout.width(4);
- cout<<A[i][j];
- }
- cout<<endl;
- }
- cout<<endl;
- }
- void csere(int &a, int &b)
- {
- int s=a;
- a=b;
- b=s;
- }
- void rendezes()
- {
- for( int i=0;i<=N-1;i++)
- for(int j=i;j<=N-1;j++)
- if(A[i][i]>A[j][j])
- csere(A[i][i],A[j][j]);
- }
- int main()
- {
- cout<<"N=";
- cin>>N;
- feltolt();
- nyomtat();
- rendezes();
- nyomtat();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement