fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. Random rnd = new Random();
  8. int[,] a = new int[3, 3];
  9. int m, n;
  10. // 二次元配列に値を代入
  11. for (m = 0; m < 3; ++m)
  12. {
  13. for (n = 0; n < 3; ++n)
  14. {
  15. a[m,n] = rnd.Next(0, 10);
  16. }
  17. }
  18. // 二次元配列に値を出力
  19. for (m = 0; m < 3; ++m)
  20. {
  21. for (n = 0; n < 3; ++n)
  22. {
  23. Console.Write(a[m,n]);
  24. }
  25. Console.WriteLine();
  26. }
  27. // 最大値と最小値を表示
  28. int max = int.MinValue;
  29. int min = int.MaxValue;
  30. for (int i = 0; i < 9; ++i)
  31. {
  32. if (max < a[m,n])
  33. {
  34. max = a[m, n];
  35. }
  36. if (min > a[m,n])
  37. {
  38. min = a[m, n];
  39. }
  40. }
  41. Console.Write(
  42. @"
  43. 最大値:{ 0}
  44. 最小値:{ 1}
  45. "
  46. , max, min);
  47. }
  48. }
  49.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(32,27): error CS0165: Use of unassigned local variable `n'
Compilation failed: 1 error(s), 0 warnings
stdout
Standard output is empty