fork(1) download
  1. using System; // matrixsortx.cs
  2. namespace matrixsort
  3. { class matrixsort
  4. { static void Main(string[] args)
  5.  
  6. { Random rand = new Random(); int i,j,k,t; int n=3, m=5;
  7. int[,] a = new int[n,m]; int[,] b = new int[n,m];
  8.  
  9. for (i=0; i<n; i++)
  10. { for (j=0; j<m; j++)
  11. { a[i,j] = rand.Next(9); b[i,j]=a[i,j];
  12. Console.Write(a[i,j]+" ");
  13. } Console.WriteLine();
  14. }
  15. Console.WriteLine();
  16.  
  17. for (i=0; i<n; i++)
  18. for (j=0; j<m-1; j++)
  19. for (k=j+1; k<m; k++)
  20. if (a[i,j]>a[i,k]) { t=a[i,j]; a[i,j]=a[i,k]; a[i,k]=t;}
  21.  
  22. for (i=0; i<n; i++)
  23. { for (j=0; j<m; j++) Console.Write(a[i,j]+" ");
  24. Console.WriteLine();
  25. }
  26. Console.WriteLine();
  27.  
  28. for (i=0; i<n; i++)
  29. { for (j=0; j<m; j++) Console.Write(b[i,j]+" ");
  30. Console.WriteLine();
  31. }
  32. Console.WriteLine();
  33.  
  34. for (j=0; j<m; j++)
  35. for (i=0; i<n-1; i++)
  36. for (k=i+1; k<n; k++)
  37. if (b[i,j]>b[k,j]) { t=b[i,j]; b[i,j]=b[k,j]; b[k,j]=t;}
  38.  
  39. for (i=0; i<n; i++)
  40. { for (j=0; j<m; j++) Console.Write(b[i,j]+" ");
  41. Console.WriteLine();
  42. }
  43. Console.WriteLine();
  44. Console.ReadKey();
  45. }}}
  46.  
Runtime error #stdin #stdout #stderr 0.08s 32904KB
stdin
Standard input is empty
stdout
0 8 2 6 8 
8 1 5 0 1 
7 2 8 2 1 

0 2 6 8 8 
0 1 1 5 8 
1 2 2 7 8 

0 8 2 6 8 
8 1 5 0 1 
7 2 8 2 1 

0 1 2 0 1 
7 2 5 2 1 
8 8 8 6 8 

stderr
Unhandled exception. System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read.
   at System.ConsolePal.ReadKey(Boolean intercept)
   at System.Console.ReadKey()
   at matrixsort.matrixsort.Main(String[] args) in /home/CNyK5O/Project/Program.cs:line 44