fork download
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace Quest
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int[] input = (from s in "4 4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 : 5 ".Split(new char[] { ' ', ':' }, StringSplitOptions.RemoveEmptyEntries)
  11. select int.Parse(s)
  12. ).ToArray();
  13.  
  14. int number = input[input.Length - 1];
  15. int index = Array.IndexOf<int>(input, number, 2) - 2;
  16. int row = index / input[1];
  17. int column = index - row * input[1];
  18.  
  19. for (int i = Math.Max(row - 1, 0); i < Math.Min(row + 2, input[0]); i++)
  20. for (int j = Math.Max(column - 1, 0); j < Math.Min(column + 2, input[1]); j++)
  21. if (i != row || j != column)
  22. {
  23. int temp = input[i * input[1] + j + 2];
  24. if (number > temp)
  25. Console.Write("{0} ", temp);
  26. }
  27. }
  28. }
  29. }
Success #stdin #stdout 0.04s 37192KB
stdin
Standard input is empty
stdout
1 2