Advertisement
Guest User

Info cu gagicile

a guest
Oct 24th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. /*int i,E=0,index=0;
  13. string s,t;
  14. var operanti = new string[20];
  15. var v=new int[20];
  16. int[] a;
  17. char[] sep = { '+', '-' };
  18. s=t=Console.ReadLine();
  19. operanti=t.Split(sep,StringSplitOptions.RemoveEmptyEntries);
  20. for (i = 0; i < operanti.Length; i++)
  21. v[i] = Convert.ToInt32(operanti[i]);
  22. E = s[0] == '-' ? -v[index] : v[index];
  23. for(i=1;i<s.Length;i++)
  24. if(s[i]=='+')
  25. {
  26. index++;
  27. E+=v[index];
  28. }
  29. else if(s[i]=='-')
  30. {
  31. index++;
  32. E-=v[index];
  33. }
  34. Console.WriteLine(E);
  35. Console.ReadKey();
  36. */
  37. int i,r=0,x=1;
  38. string s;
  39. int[]op = new int[10];
  40. string[] v = new string[10];
  41. char[]sep={'+','-'};
  42. s=Console.ReadLine();
  43. v=s.Split(sep,StringSplitOptions.RemoveEmptyEntries);
  44. for(i=0;i<v.Length;i++)
  45. op[i]=Convert.ToInt32(v[i]);
  46. if(s[0]=='-')
  47. r=-op[0];
  48. else
  49. r=op[0];
  50. for(i=1;i<s.Length;i++)
  51. if(s[i]=='+')
  52. {r+=op[x];x++;}
  53. else if(s[i]=='-')
  54. {r=op[x];x++;}
  55. Console.WriteLine(r);
  56. Console.ReadKey();
  57. }
  58.  
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement