Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.27 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Globalization;
  6. using System.Text.RegularExpressions;
  7.  
  8.  
  9. namespace ConsoleApplication27
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. Console.WriteLine("Zadanie 1-3");
  16. Console.WriteLine(" ");
  17. Console.WriteLine("Podaj liczby oddzielone przecinkami");
  18. string wejscie = Console.ReadLine();
  19. string[] cyfry = wejscie.Split(',');
  20.  
  21. int max = cyfry.Length;
  22.  
  23. int[] tab1 = new int[max];
  24. int[] tab2 = new int[max];
  25.  
  26. int i = 0;
  27.  
  28. while (i < max)
  29. {
  30. try
  31. {
  32. tab1[i] = int.Parse(cyfry[i]);
  33. tab2[i] = tab1[i] * tab1[i];
  34. }
  35. catch
  36. {
  37. tab1[i] = 0;
  38. tab2[i] = 0;
  39. }
  40. i++;
  41. }
  42.  
  43. i = 0;
  44. while (i < max)
  45. {
  46. if (tab1[i] == 0)
  47. {
  48. Console.WriteLine("0");
  49. }
  50. else
  51. {
  52. Console.WriteLine(tab1[i] + "^2 = " + tab2[i]);
  53. }
  54. i++;
  55.  
  56. }
  57.  
  58. Console.ReadKey();
  59. Console.Clear();
  60. Console.WriteLine("Zadanie 4-5");
  61. Console.WriteLine(" ");
  62.  
  63. Console.WriteLine("CurrentCulture is {0}.", CultureInfo.CurrentCulture.Name);
  64.  
  65. CultureInfo ciPl = new CultureInfo("pl-PL");
  66. CultureInfo ciUs = new CultureInfo("en-US");
  67. CultureInfo ciGb = new CultureInfo("en-GB");
  68. CultureInfo ciHe = new CultureInfo("he-IL");
  69. CultureInfo ciRu = new CultureInfo("ar-SA");
  70. CultureInfo[] ciTab = { ciPl, ciUs, ciGb, ciHe, ciRu };
  71.  
  72. CultureInfo ci;
  73. String s;
  74. Int32 i2;
  75. Console.WriteLine(Console.InputEncoding.CodePage);
  76.  
  77. for (i2 = 0; i2 < ciTab.Length; i2++)
  78. {
  79. ci = ciTab[i2];
  80. s = String.Format(ci, "CI: {0}, data: {1:f}, waluta: {2:C}", ci.Name, DateTime.Now, -123, 456);
  81. Console.WriteLine(s);
  82. }
  83.  
  84. Console.ReadKey();
  85. Console.Clear();
  86. Console.WriteLine("Zadanie 6");
  87. Console.WriteLine(" ");
  88. Console.WriteLine("Wpisz jakies zdanie i jakies liczby");
  89. string zdanie = Console.ReadLine();
  90. char[] pojedyncze = zdanie.ToCharArray();
  91.  
  92. for (int i4 = 0; i4 < pojedyncze.Length; i4++)
  93. {
  94. if (Char.IsDigit(pojedyncze[i4]))
  95. {
  96. Console.WriteLine(pojedyncze[i4]+",");
  97. }
  98. }
  99.  
  100. Console.ReadKey();
  101. Console.Clear();
  102. Console.WriteLine("Zadanie 7");
  103. Console.WriteLine(" ");
  104. Console.WriteLine("Wpisz jakies zdanie i jakies liczby");
  105. string zdanie2 = Console.ReadLine();
  106. string[] tylkoLiczby = Regex.Split(zdanie2, @"\D+");
  107. foreach (string value in tylkoLiczby)
  108. {
  109. if(!string.IsNullOrEmpty(value)){
  110. int i5 = int.Parse(value);
  111. Console.WriteLine("Liczba -> {0}", i5);
  112. }
  113. }
  114.  
  115. Console.ReadKey();
  116. Console.Clear();
  117. Console.WriteLine("Zadanie 8");
  118. Console.WriteLine(" ");
  119. Console.WriteLine("MENU: ");
  120. Console.WriteLine("a, 1–wczytanie liczby a");
  121. Console.WriteLine("b, 2–wczytanie liczby b");
  122. Console.WriteLine("+, s–obliczenie sumy a i b");
  123. Console.WriteLine("-, r–obliczenie różnicy a i b");
  124. Console.WriteLine("=, m–wyświetlanie menu");
  125. Console.WriteLine("#, x–wyjście z programu");
  126. string wybor = Convert.ToString(Console.ReadKey());
  127.  
  128. switch (wybor)
  129. {
  130. case "a" "1":
  131.  
  132.  
  133. }
  134.  
  135.  
  136. Console.ReadKey();
  137.  
  138. }
  139. }
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement