fork(1) download
  1. #include <stdio.h>
  2.  
  3. #include <stdlib.h>
  4.  
  5. int main()
  6.  
  7. {
  8.  
  9. int mas[ 50 ][ 50 ];
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17. printf( "Vvedite razmer matrici\n" );
  18.  
  19. srand( 624 );
  20.  
  21. //srand( 1 );
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29. int i, j, a, b;
  30.  
  31. scanf( "%d %d", &a, &b );
  32.  
  33. //a = 20; b = 4;
  34.  
  35. //a = 7; b = 4;
  36.  
  37.  
  38.  
  39. for( i = 0; i < a; i++ )
  40.  
  41. {
  42.  
  43. for( j = 0; j < b; j++ )
  44.  
  45. {
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53. mas[ i ][ j ] = ( double )rand() / ( RAND_MAX + 1 ) * 99 + 1;
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. printf( "%3d", mas[ i ][ j ] );
  62.  
  63. }
  64.  
  65. printf("\n");
  66.  
  67. }
  68.  
  69. int x,y;
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77. for( y = 0; y < a; y++ )
  78.  
  79. {
  80.  
  81. for ( i = 0; i < ( a - 1 ); i++ )
  82.  
  83. {
  84.  
  85. if( mas[ i ][ 0 ] > mas[ i + 1 ][ 0 ] )
  86.  
  87. {
  88.  
  89. for( j = 0 ; j < b; j++ )
  90.  
  91. {
  92.  
  93. x = mas[ i ][ j ];
  94.  
  95. mas[ i ][ j ] = mas[ i + 1 ][ j ];
  96.  
  97. mas[ i + 1 ][ j ] = x;
  98.  
  99. }
  100.  
  101. }
  102.  
  103. }
  104.  
  105. }
  106.  
  107. printf("\n");
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115. for( i = 0; i < a; i++ )
  116.  
  117. {
  118.  
  119. for( j = 0; j < b; j++ )
  120.  
  121. {
  122.  
  123. printf( "%3d", mas[ i ][ j ] );
  124.  
  125. }
  126.  
  127. printf("\n");
  128.  
  129. }
  130.  
  131.  
  132.  
  133.  
  134.  
  135. system("pause");
  136.  
  137. return 0;
  138.  
  139. }
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
Success #stdin #stdout #stderr 0s 3344KB
stdin
10  15
stdout
Vvedite razmer matrici
-59-72-81-70-79-25-73 -5 -9-29-36-97-37-26-71
-26-28-85-54-44-10-33-52-52-27 -6-82 -1-70-26
-41-32  0-25 -5-80-52-79-87-62-11-26-61-49-53
-35-77-82-22-33-29-34-68-82-87-97-90-71  0-62
  0-43-96 -1-70 -3-83-24-84-73-87-97 -1-51-49
-56-87-28-40-11-63-71-47-33-56-36-33-48-10-35
-13-11-79-11-13-51-16-97-77 -3-73-66 -2-75-19
-52-33 -8-82-75-21-47-48-69-82 -6 -8-17-55-19
-53-70-32-35-82-46-88 -1-46-67 -5-21-35 -9  0
-55-63-33-65-47-10-88-96-60-59-80-67-68  0-25

-59-72-81-70-79-25-73 -5 -9-29-36-97-37-26-71
-56-87-28-40-11-63-71-47-33-56-36-33-48-10-35
-55-63-33-65-47-10-88-96-60-59-80-67-68  0-25
-53-70-32-35-82-46-88 -1-46-67 -5-21-35 -9  0
-52-33 -8-82-75-21-47-48-69-82 -6 -8-17-55-19
-41-32  0-25 -5-80-52-79-87-62-11-26-61-49-53
-35-77-82-22-33-29-34-68-82-87-97-90-71  0-62
-26-28-85-54-44-10-33-52-52-27 -6-82 -1-70-26
-13-11-79-11-13-51-16-97-77 -3-73-66 -2-75-19
  0-43-96 -1-70 -3-83-24-84-73-87-97 -1-51-49
stderr
sh: pause: not found