Advertisement
Guest User

1234

a guest
Oct 20th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Text.RegularExpressions;
  7.  
  8. namespace Taschenrechner
  9. {
  10. class Rechner
  11. {
  12. private static string[] EingabeArray;
  13. public static void Einlesen(string eingabe)
  14. {
  15. int length = 0;
  16.  
  17. string Rechenterm = eingabe;
  18. // prüfung der "" leermengen
  19. foreach (string result in Regex.Split(Rechenterm, @"([+\-*/()]|SQRT\()"))
  20. {
  21. if (result != "") { length++; }
  22. }
  23.  
  24. // Längen definition
  25. EingabeArray = new string[length];
  26.  
  27. // Länge je nachdem wie viele Leerzeichen nach dem split drinne waren
  28. length = 0;
  29.  
  30. foreach (string result in Regex.Split(Rechenterm, @"([+\-*/()]|SQRT\()"))
  31. {
  32. if (result != "")
  33. {
  34. EingabeArray[length] = "' " + result + " '";
  35. length++;
  36. }
  37. }
  38.  
  39.  
  40. for (int i = 0; i < EingabeArray.Length; i++)
  41. Console.WriteLine("Index:"+i+ " " +EingabeArray[i]);
  42. }
  43. }
  44. class Program
  45. {
  46. static void Main(string[] args)
  47. {
  48. string Test = "1234/11*(23+32)";
  49. Rechner.Einlesen(Test);
  50. Console.ReadKey();
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement