fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication4
  8. {
  9. class Program
  10. {
  11.  
  12.  
  13.  
  14. static void Main(string[] args)
  15. {
  16.  
  17.  
  18.  
  19.  
  20.  
  21. List<int> intarray = new List<int>();
  22.  
  23. // string input = Console.ReadLine();
  24. // int[] arrayInt = stringToIntArray("7 2 0 1 3 4 9 5");
  25.  
  26. string a = "7 2 0 1 3 4 9 5";
  27.  
  28. List<int> big = new List<int>();
  29.  
  30. int start = 0, end = 0;
  31.  
  32.  
  33. for (int i = 0; i < a.Length; i += 2)
  34. {
  35.  
  36. for (int k = 1; k < a.Length; k += 2)
  37. {
  38.  
  39. intarray.Clear();
  40. try
  41. {
  42. intarray.AddRange(stringToIntArray(a.Substring(i, k)));
  43. }
  44. catch (Exception)
  45. {
  46. intarray.AddRange(stringToIntArray(a.Substring(i)));
  47.  
  48.  
  49. }
  50. intarray.Sort();
  51.  
  52. if (intarray[intarray.Count - 1] - intarray[0] == intarray.Count - 1)
  53. {
  54. if (intarray.Count > big.Count || big.Count == 0)
  55. {
  56. big.Clear();
  57. big.AddRange(intarray);
  58. start = i;
  59. end = k;
  60. }
  61. }
  62.  
  63.  
  64. }
  65.  
  66.  
  67. }
  68. Console.WriteLine(a.Substring(start, end));
  69.  
  70.  
  71.  
  72.  
  73.  
  74. Console.ReadKey();
  75. }
  76.  
  77. static int[] stringToIntArray(string input)
  78. {
  79.  
  80. string[] x = input.Split(' ');
  81. int[] arrayInt = new int[x.Length];
  82. for (int i = 0; i < x.Length; i++)
  83. {
  84. arrayInt[i] = Convert.ToInt32(x[i]);
  85. }
  86.  
  87. return arrayInt;
  88. }
  89. }
  90. }
  91.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class, interface, or enum expected
using System;
^
Main.java:2: error: class, interface, or enum expected
using System.Collections.Generic;
^
Main.java:3: error: class, interface, or enum expected
using System.Linq;
^
Main.java:4: error: class, interface, or enum expected
using System.Text;
^
Main.java:5: error: class, interface, or enum expected
using System.Threading.Tasks;
^
Main.java:7: error: class, interface, or enum expected
namespace ConsoleApplication4
^
Main.java:60: error: <identifier> expected
                    catch (Exception)
                                    ^
Main.java:106: error: class, interface, or enum expected
}
^
8 errors
stdout
Standard output is empty