Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<string> memory = new List<string> { };
- string display = "";
- while (display.Contains("%") == false)
- {
- string line = ReadLine();
- display = line;
- memory.Add(line);
- }
- float result = float.Parse(memory[0]);
- for (int i = 1; i < memory.Count; i++)
- {
- string temp = memory[i];
- char[] _temp = temp.ToCharArray();
- _temp = _temp.Where(x => x > _temp[0]).ToArray();
- float num = float.Parse(string.Join("", _temp));
- if (temp.Contains("+") == true) result += num;
- else if (temp.Contains("-") == true) result -= num;
- else if (temp.Contains("*") == true) result *= num;
- else if (temp.Contains("/") == true) result /= num;
- else if (temp.Contains("%") == true) result %= num;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement