Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- /*int i,E=0,index=0;
- string s,t;
- var operanti = new string[20];
- var v=new int[20];
- int[] a;
- char[] sep = { '+', '-' };
- s=t=Console.ReadLine();
- operanti=t.Split(sep,StringSplitOptions.RemoveEmptyEntries);
- for (i = 0; i < operanti.Length; i++)
- v[i] = Convert.ToInt32(operanti[i]);
- E = s[0] == '-' ? -v[index] : v[index];
- for(i=1;i<s.Length;i++)
- if(s[i]=='+')
- {
- index++;
- E+=v[index];
- }
- else if(s[i]=='-')
- {
- index++;
- E-=v[index];
- }
- Console.WriteLine(E);
- Console.ReadKey();
- */
- int i,r=0,x=1;
- string s;
- int[]op = new int[10];
- string[] v = new string[10];
- char[]sep={'+','-'};
- s=Console.ReadLine();
- v=s.Split(sep,StringSplitOptions.RemoveEmptyEntries);
- for(i=0;i<v.Length;i++)
- op[i]=Convert.ToInt32(v[i]);
- if(s[0]=='-')
- r=-op[0];
- else
- r=op[0];
- for(i=1;i<s.Length;i++)
- if(s[i]=='+')
- {r+=op[x];x++;}
- else if(s[i]=='-')
- {r=op[x];x++;}
- Console.WriteLine(r);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement