Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.47 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 ConsoleApplication2
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             //zad 1
  15.             string s = "Kordos_0117.zip";
  16.             string pattern = @"^[A-Z][a-z]{2,14}_(0[0-9]|1[0-2])(0[0-9]|[1-2][0-9]|3[0-1])\.zip$";
  17.             if (Regex.IsMatch(s, pattern))
  18.             {
  19.                 Console.WriteLine("true");
  20.  
  21.             }
  22.             else
  23.             {
  24.                 Console.WriteLine("false");
  25.             }
  26.  
  27.             //zad 2
  28.             var L1 = new List<C>();
  29.  
  30.             for (int i = 0; i < 10; i++)
  31.             {
  32.                 L1.Add(new C());
  33.                 for (int j = 0; j < 10; j++)
  34.                 {
  35.                     L1[i].D.Add(j,j+5);
  36.                 }
  37.             }
  38.  
  39.             var L2 = new List<C>();
  40.  
  41.             for (int i = 0; i < 10; i++)
  42.             {
  43.                 L2.Add(new C());
  44.                 for (int j = 0; j < 10; j++)
  45.                 {
  46.                     L2[i].D.Add(L1[i].D.Keys.ElementAt(j),L1[i].D[j]);
  47.                 }
  48.             }
  49.  
  50.             L1[2].D[2] = 3;
  51.             Console.WriteLine(L1[2].D[2]);
  52.             Console.WriteLine(L2[2].D[2]);
  53.  
  54.             var rnd= new Random();
  55.             var T1 = new int[30];
  56.             var T2 = new int[30];
  57.  
  58.             for (int i = 0; i < 30; i++)
  59.             {
  60.                 T1[i] = rnd.Next(0, 40);
  61.                 T2[i] = rnd.Next(0, 40);
  62.             }
  63.  
  64.             T1.Where(x=>x%2!=0).
  65.                 OrderBy(x=>x).
  66.                 ToList().
  67.                 ForEach(x=>Console.WriteLine(x));
  68.  
  69.             T1.Skip(3).
  70.                 Take(10).
  71.                 Where(x => x % 2 != 0).
  72.                 OrderBy(x => x).
  73.                 ToList().
  74.                 ForEach(x => Console.WriteLine(x));
  75.  
  76.             Console.WriteLine();
  77.             T1.Intersect(T2).Where(x=>x>20).ToList().ForEach(x=>Console.WriteLine(x));
  78.  
  79.             Console.WriteLine();
  80.             T1.Except(T2).Where(x => x > 20).ToList().ForEach(x => Console.WriteLine(x));
  81.  
  82.             Console.WriteLine();
  83.             var vari = Math.Sqrt( T1.Sum(x => Math.Pow( x,2))-Math.Pow(T1.Sum(x => x),2));
  84.             Console.WriteLine(vari);
  85.         }
  86.     }
  87.  
  88.     class C
  89.     {
  90.         public Dictionary<int, int> D = new Dictionary<int, int>();
  91.  
  92.  
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement