Advertisement
Guest User

Untitled

a guest
Apr 18th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <ctime>
  3. #include <iostream>
  4. #include <stdio.h>
  5. #include <conio.h>
  6. using namespace std;
  7.  
  8. int init(int a[50][50],int b,int c)
  9. {
  10.         for (int i=0;i<b;i++)
  11.                 for (int j=0;j<c;j++)
  12.         {
  13.                 a[i][j]=-100+rand()%(200);
  14.         }
  15. }
  16. int sort(int a[50][50], int b,int c)
  17. {
  18.         int k=0;int s=a[0][0];int s1;
  19.         for(int h=0;h<b;h++)
  20.         {
  21.         int j=0;
  22.         s=a[k][0];
  23.         for (short l=k;l<b;l++)
  24.                 if(s>a[l][0]) {j=l;s=a[l][0];}
  25.         if(j==0)
  26.                 for (short l=k;l<b;l++)
  27.                         if(s==a[l][0]) {j=l;s=a[l][0];}
  28.  
  29.  
  30.         if(j!=0)
  31.         {
  32.         for (int g=0;g<c;g++)
  33.         {
  34.                 s1=a[k][g];
  35.                 a[k][g]=a[j][g];
  36.                 a[j][g]=s1;
  37.         }
  38.         k++;
  39.         }
  40.         else
  41.                 k++;
  42.  
  43.  
  44.         }
  45. }
  46.  
  47. int massout(int a[50][50] , int b, int c)
  48. {
  49.         for(int i=0;i<b;i++)
  50.                 {cout<<'\n';
  51.                 for(int j=0;j<c;j++)
  52.                         cout<<a[i][j]<<' ';}
  53.         cout<<"\n\n\n";
  54. }
  55. int main()
  56. {
  57.         srand(time(0));
  58.         int a[50][50];
  59.         int o,u;
  60.         cin>>o>>u;
  61.         init(a,o,u);
  62.         massout(a,o,u);
  63.         sort(a,o,u);
  64.         massout(a,o,u);
  65.  
  66.      system("pause");
  67.     return 0;
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement