fork download
  1. using static System.Console;
  2.  
  3. public class Program {
  4. public static void Main() {
  5. int[,] array = new int[10,10];
  6. for (int l = 0; l < 10; l++) {
  7. for (int c = 0; c < 10; c++) array[l, c] = c;
  8. }
  9. for (int l = 0; l < 10; l++) {
  10. for (int c = 0; c < 10; c++) Write($"{array[l, c]} ");
  11. WriteLine();
  12. }
  13. WriteLine();
  14. for (int l = 0; l < 10; l++) {
  15. for (int c = l; c < 10; c++) { // <========== mudei aqui, veja o l
  16. int temp = array[l, c];
  17. array[l, c] = array[c, l];
  18. array[c, l] = temp;
  19. }
  20. }
  21. for (int l = 0; l < 10; l++) {
  22. for (int c = 0; c < 10; c++) Write($"{array[l, c]} ");
  23. WriteLine();
  24. }
  25. }
  26. }
  27.  
  28. //https://pt.stackoverflow.com/q/220469/101
Success #stdin #stdout 0.02s 16168KB
stdin
Standard input is empty
stdout
0 1 2 3 4 5 6 7 8 9 
0 1 2 3 4 5 6 7 8 9 
0 1 2 3 4 5 6 7 8 9 
0 1 2 3 4 5 6 7 8 9 
0 1 2 3 4 5 6 7 8 9 
0 1 2 3 4 5 6 7 8 9 
0 1 2 3 4 5 6 7 8 9 
0 1 2 3 4 5 6 7 8 9 
0 1 2 3 4 5 6 7 8 9 
0 1 2 3 4 5 6 7 8 9 

0 0 0 0 0 0 0 0 0 0 
1 1 1 1 1 1 1 1 1 1 
2 2 2 2 2 2 2 2 2 2 
3 3 3 3 3 3 3 3 3 3 
4 4 4 4 4 4 4 4 4 4 
5 5 5 5 5 5 5 5 5 5 
6 6 6 6 6 6 6 6 6 6 
7 7 7 7 7 7 7 7 7 7 
8 8 8 8 8 8 8 8 8 8 
9 9 9 9 9 9 9 9 9 9