Advertisement
Pavle_nis

C#

Jan 20th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. List<string> n_and_o(string cad)
  2.         {
  3.             List<string> list = new List<string>();
  4.  
  5.             for (int i = 0; i < cad.Length; i++)
  6.             {
  7.                 if (cad[i] == '+')
  8.                 {
  9.                     list.Add("suma");
  10.                 }
  11.                 if (cad[i] == '-')
  12.                 {
  13.                     list.Add("resta");
  14.                 }
  15.                 if (cad[i] == '*')
  16.                 {
  17.                     list.Add("multi");
  18.                 }
  19.                 if (cad[i] == '/')
  20.                 {
  21.                     list.Add("div");
  22.                 }
  23.             }
  24.  
  25.             return list;
  26.         }
  27.         List<int> n_and_o_1(string cad)
  28.         {
  29.             List<int> nums = new List<int>();
  30.  
  31.             foreach(var x in cad.Replace('+', ' ').Replace('-', ' ').Replace('*', ' ').Replace('/', ' ').Split())
  32.             {
  33.                 nums.Add(Convert.ToInt32(x));
  34.                 Console.WriteLine(x);
  35.             }
  36.  
  37.             return nums;
  38.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement