Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. List<string> memory = new List<string> { };
  2.  
  3. string display = "";
  4. while (display.Contains("%") == false)
  5. {
  6. string line = ReadLine();
  7. display = line;
  8. memory.Add(line);
  9. }
  10.  
  11. float result = float.Parse(memory[0]);
  12.  
  13. for (int i = 1; i < memory.Count; i++)
  14. {
  15. string temp = memory[i];
  16. char[] _temp = temp.ToCharArray();
  17. _temp = _temp.Where(x => x > _temp[0]).ToArray();
  18. float num = float.Parse(string.Join("", _temp));
  19.  
  20. if (temp.Contains("+") == true) result += num;
  21. else if (temp.Contains("-") == true) result -= num;
  22. else if (temp.Contains("*") == true) result *= num;
  23. else if (temp.Contains("/") == true) result /= num;
  24. else if (temp.Contains("%") == true) result %= num;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement