Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Globalization;
- using System.Text.RegularExpressions;
- namespace ConsoleApplication27
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Zadanie 1-3");
- Console.WriteLine(" ");
- Console.WriteLine("Podaj liczby oddzielone przecinkami");
- string wejscie = Console.ReadLine();
- string[] cyfry = wejscie.Split(',');
- int max = cyfry.Length;
- int[] tab1 = new int[max];
- int[] tab2 = new int[max];
- int i = 0;
- while (i < max)
- {
- try
- {
- tab1[i] = int.Parse(cyfry[i]);
- tab2[i] = tab1[i] * tab1[i];
- }
- catch
- {
- tab1[i] = 0;
- tab2[i] = 0;
- }
- i++;
- }
- i = 0;
- while (i < max)
- {
- if (tab1[i] == 0)
- {
- Console.WriteLine("0");
- }
- else
- {
- Console.WriteLine(tab1[i] + "^2 = " + tab2[i]);
- }
- i++;
- }
- Console.ReadKey();
- Console.Clear();
- Console.WriteLine("Zadanie 4-5");
- Console.WriteLine(" ");
- Console.WriteLine("CurrentCulture is {0}.", CultureInfo.CurrentCulture.Name);
- CultureInfo ciPl = new CultureInfo("pl-PL");
- CultureInfo ciUs = new CultureInfo("en-US");
- CultureInfo ciGb = new CultureInfo("en-GB");
- CultureInfo ciHe = new CultureInfo("he-IL");
- CultureInfo ciRu = new CultureInfo("ar-SA");
- CultureInfo[] ciTab = { ciPl, ciUs, ciGb, ciHe, ciRu };
- CultureInfo ci;
- String s;
- Int32 i2;
- Console.WriteLine(Console.InputEncoding.CodePage);
- for (i2 = 0; i2 < ciTab.Length; i2++)
- {
- ci = ciTab[i2];
- s = String.Format(ci, "CI: {0}, data: {1:f}, waluta: {2:C}", ci.Name, DateTime.Now, -123, 456);
- Console.WriteLine(s);
- }
- Console.ReadKey();
- Console.Clear();
- Console.WriteLine("Zadanie 6");
- Console.WriteLine(" ");
- Console.WriteLine("Wpisz jakies zdanie i jakies liczby");
- string zdanie = Console.ReadLine();
- char[] pojedyncze = zdanie.ToCharArray();
- for (int i4 = 0; i4 < pojedyncze.Length; i4++)
- {
- if (Char.IsDigit(pojedyncze[i4]))
- {
- Console.WriteLine(pojedyncze[i4]+",");
- }
- }
- Console.ReadKey();
- Console.Clear();
- Console.WriteLine("Zadanie 7");
- Console.WriteLine(" ");
- Console.WriteLine("Wpisz jakies zdanie i jakies liczby");
- string zdanie2 = Console.ReadLine();
- string[] tylkoLiczby = Regex.Split(zdanie2, @"\D+");
- foreach (string value in tylkoLiczby)
- {
- if(!string.IsNullOrEmpty(value)){
- int i5 = int.Parse(value);
- Console.WriteLine("Liczba -> {0}", i5);
- }
- }
- Console.ReadKey();
- Console.Clear();
- Console.WriteLine("Zadanie 8");
- Console.WriteLine(" ");
- Console.WriteLine("MENU: ");
- Console.WriteLine("a, 1–wczytanie liczby a");
- Console.WriteLine("b, 2–wczytanie liczby b");
- Console.WriteLine("+, s–obliczenie sumy a i b");
- Console.WriteLine("-, r–obliczenie różnicy a i b");
- Console.WriteLine("=, m–wyświetlanie menu");
- Console.WriteLine("#, x–wyjście z programu");
- string wybor = Convert.ToString(Console.ReadKey());
- switch (wybor)
- {
- case "a" "1":
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement