fork(1) download
  1. using System;
  2.  
  3. namespace ConsoleApp7
  4. {
  5. class Program
  6. {
  7. static void Main()
  8. {
  9. int num = 2;
  10. int numb = 0;
  11. int a = 0, b = 0, c = 0;
  12. string line = null;
  13. string linea = null;
  14. string lineb = null;
  15. bool atrue = true;
  16. bool btrue = false;
  17.  
  18. for (int i = 0; i < 100; i++)
  19. {
  20. line = Console.ReadLine();
  21. line += line + " ";
  22. if (line != null)
  23. {
  24.  
  25. while (atrue)
  26. {
  27. if(Char.IsWhiteSpace(line, num))
  28. {
  29. atrue = false;
  30.  
  31. btrue = true;
  32. numb = num ;
  33. linea = line.Substring(2, num - 2);
  34.  
  35.  
  36.  
  37. }
  38. else
  39. {
  40. num++;
  41.  
  42. }
  43.  
  44. }
  45. while (btrue)
  46. {
  47.  
  48. if (Char.IsWhiteSpace(line, numb + 1))
  49. {
  50. btrue = false;
  51.  
  52. lineb = line.Substring(num+1,numb-num-1);
  53.  
  54.  
  55.  
  56.  
  57. }
  58. else
  59. {
  60. numb++;
  61.  
  62. }
  63.  
  64. }
  65.  
  66.  
  67. a = int.Parse(linea);
  68. b = int.Parse(lineb);
  69.  
  70.  
  71.  
  72.  
  73. if (line[0] == '+')
  74. {
  75.  
  76. c = a + b;
  77. Console.WriteLine(c);
  78.  
  79. }
  80. if (line[0] == '-')
  81. {
  82. c = a - b;
  83. Console.WriteLine(c);
  84. }
  85. if (line[0] == '*')
  86. {
  87. c = a * b;
  88. Console.WriteLine(c);
  89. }
  90. if (line[0] == '/')
  91. {
  92. c = a / b;
  93. Console.WriteLine(c);
  94. }
  95. if (line[0] == '%')
  96. {
  97. c = a % b;
  98. Console.WriteLine(c);
  99. }
  100.  
  101. atrue = true;
  102. btrue = true;
  103.  
  104. }
  105. else return;
  106.  
  107. }
  108. }
  109. }
  110. }
  111.  
Runtime error #stdin #stdout #stderr 0.02s 16176KB
stdin
+ 7 9
- 0 4
* 5 6
/ 8 3
% 5 2
stdout
16
-4
30
2
1
stderr
Unhandled Exception:
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
  at System.Char.IsWhiteSpace (System.String s, System.Int32 index) [0x00017] in <6649516e5b3542319fb262b421af0adb>:0 
  at ConsoleApp7.Program.Main () [0x00045] in <df00e68514a34ae6a6f2e633abb82d3c>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
  at System.Char.IsWhiteSpace (System.String s, System.Int32 index) [0x00017] in <6649516e5b3542319fb262b421af0adb>:0 
  at ConsoleApp7.Program.Main () [0x00045] in <df00e68514a34ae6a6f2e633abb82d3c>:0