fork(1) 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 ConsoleApplication35
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int num, i = 0;
  14. string fun, operation;
  15. Console.WriteLine("Input function: ");
  16. string f = Console.ReadLine();
  17. fun = convert(f);
  18. Console.WriteLine(fun);
  19. q1(ref fun, ref i);
  20. Console.WriteLine("Resulte = " + fun);
  21. Console.WriteLine("Resulte(10) = " + unconverte(fun));
  22. }
  23. int unconvert(string f)
  24. {
  25. int n = 0,i=0;
  26. for (i = 0; i < f.Length; i++)
  27. {
  28. if (f[i] == '1') n++;
  29. }
  30. return n;
  31. }
  32. string convert(int num){
  33. string res=null;
  34. while (num >= 0){
  35. res+='1';
  36. num--;
  37. }
  38. return res;
  39. }
  40. string convert(string f){
  41. string s_num, res;
  42. int num,i= 0;
  43. while ( i < f.Length) {
  44. if ((f[i] =='+') || (f[i] == '-')){
  45. num = stoi(s_num);
  46. res += convert(num);
  47. res+=f[i];
  48. s_num = "";
  49. i++;
  50. }
  51. s_num += f[i];
  52. i++;
  53. }
  54. num = stoi(s_num);
  55. res += convert(num);
  56. return res;
  57. }
  58. void q1(ref string fun, ref int i){
  59. if (fun[i] == '+'){
  60. q6(ref fun, ref i);
  61. return;
  62. }
  63. else if (fun[i] == '-'){
  64. q7(ref fun, ref i);
  65. return;
  66. }
  67. else if (i >= fun.Length){
  68. return;
  69. }
  70. i++;
  71. q1(ref fun, ref i);
  72. }
  73. void q2(ref string fun, ref int i){
  74. i--;
  75. if (fun[i] == '1') {
  76. i++;
  77. q9(ref fun, ref i);
  78. return;
  79. }
  80. q2(ref fun, ref i);
  81. }
  82. void q3(ref string fun, ref int i){
  83. i++;
  84. if (fun[i] == '1'){
  85. fun[i] = ' ';
  86. Console.WriteLine(fun);
  87. q2(ref fun, ref i);
  88. return;
  89. }
  90. else if (fun[i] == '+'){
  91. q6(ref fun, ref i);
  92. return;
  93. }
  94. else if (fun[i] == '-'){
  95. q7(ref fun, ref i);
  96. return;
  97. }
  98. else if (i >= fun.Length){
  99. return;
  100. }
  101. q3(ref fun, ref i);
  102. }
  103. void q4(ref string fun, ref int i){
  104. i--;
  105. if (fun[i] == '1') {
  106. fun[i] = ' ';
  107. Console.WriteLine(fun);
  108. q5(ref fun, ref i);
  109. return;
  110. }
  111. q4(ref fun, ref i);
  112. }
  113. void q5(ref string fun, ref int i){
  114. i++;
  115. if (fun[i] == '1'){
  116. fun[i] = ' ';
  117. Console.WriteLine(fun);
  118. q4(ref fun, ref i);
  119. return;
  120. }
  121. else if (fun[i] == '+'){
  122. q6(ref fun, ref i);
  123. return;
  124. }
  125. else if (fun[i] == '-'){
  126. q7(ref fun, ref i);
  127. return;
  128. }
  129. else if (i >= fun.Length){
  130. return;
  131. }
  132. q5(ref fun, ref i);
  133. }
  134. void q6(ref string fun, ref int i){
  135. fun[i] = ' ';
  136. i++;
  137. q10(ref fun, ref i);
  138. }
  139. void q7(ref string fun, ref int i){
  140. fun[i] = ' ';
  141. i++;
  142. q8(ref fun, ref i);
  143. }
  144. void q8(ref string fun, ref int i){
  145. fun[i] =' ';
  146. Console.WriteLine(fun);
  147. q4(ref fun, ref i);
  148. }
  149. void q9(ref string fun, ref int i){
  150. fun[i] = '1';
  151. Console.WriteLine(fun);
  152. q3(ref fun, ref i);
  153. }
  154. void q10(ref string fun, ref int i){
  155. fun[i] = ' ';
  156. Console.WriteLine(fun);
  157. q2(ref fun, ref i);
  158. }
  159. }
  160. }
  161.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(17,19): error CS0120: An object reference is required to access non-static member `ConsoleApplication35.Program.convert(string)'
prog.cs(19,13): error CS0120: An object reference is required to access non-static member `ConsoleApplication35.Program.q1(ref string, ref int)'
prog.cs(21,50): error CS0103: The name `unconverte' does not exist in the current context
prog.cs(45,10): error CS0103: The name `stoi' does not exist in the current context
prog.cs(54,8): error CS0103: The name `stoi' does not exist in the current context
prog.cs(85,6): error CS0200: Property or indexer `string.this[int]' cannot be assigned to (it is read-only)
prog.cs(106,6): error CS0200: Property or indexer `string.this[int]' cannot be assigned to (it is read-only)
prog.cs(116,6): error CS0200: Property or indexer `string.this[int]' cannot be assigned to (it is read-only)
prog.cs(135,5): error CS0200: Property or indexer `string.this[int]' cannot be assigned to (it is read-only)
prog.cs(140,5): error CS0200: Property or indexer `string.this[int]' cannot be assigned to (it is read-only)
prog.cs(145,5): error CS0200: Property or indexer `string.this[int]' cannot be assigned to (it is read-only)
prog.cs(150,5): error CS0200: Property or indexer `string.this[int]' cannot be assigned to (it is read-only)
prog.cs(155,5): error CS0200: Property or indexer `string.this[int]' cannot be assigned to (it is read-only)
Compilation failed: 13 error(s), 0 warnings
stdout
Standard output is empty