Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <ctime>
- #include <iostream>
- #include <stdio.h>
- #include <conio.h>
- using namespace std;
- int init(int a[50][50],int b,int c)
- {
- for (int i=0;i<b;i++)
- for (int j=0;j<c;j++)
- {
- a[i][j]=-100+rand()%(200);
- }
- }
- int sort(int a[50][50], int b,int c)
- {
- int k=0;int s=a[0][0];int s1;
- for(int h=0;h<b;h++)
- {
- int j=0;
- s=a[k][0];
- for (short l=k;l<b;l++)
- if(s>a[l][0]) {j=l;s=a[l][0];}
- if(j==0)
- for (short l=k;l<b;l++)
- if(s==a[l][0]) {j=l;s=a[l][0];}
- if(j!=0)
- {
- for (int g=0;g<c;g++)
- {
- s1=a[k][g];
- a[k][g]=a[j][g];
- a[j][g]=s1;
- }
- k++;
- }
- else
- k++;
- }
- }
- int massout(int a[50][50] , int b, int c)
- {
- for(int i=0;i<b;i++)
- {cout<<'\n';
- for(int j=0;j<c;j++)
- cout<<a[i][j]<<' ';}
- cout<<"\n\n\n";
- }
- int main()
- {
- srand(time(0));
- int a[50][50];
- int o,u;
- cin>>o>>u;
- init(a,o,u);
- massout(a,o,u);
- sort(a,o,u);
- massout(a,o,u);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement