Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. static void Main(string[] args)
  2.         {
  3.  
  4.             string napis = "sdaaaa.ssssssssssd.aaaaaaaa.d";
  5.             string[] podzielony = Podziel(napis, '.');
  6.  
  7.             for (int i = 0; i < 4; i++)
  8.             {
  9.                 Console.WriteLine(podzielony[i]);
  10.             }
  11.  
  12.             Console.ReadKey();
  13.         }
  14.  
  15.        
  16.         static string[] Podziel(string napis, char delimeter)
  17.         {
  18.             int l = 0, rozmiarTablicy = 1, pierwszaLitera = 0;
  19.  
  20.             while (l < napis.Length)
  21.             {
  22.                 if (napis[l] == delimeter) rozmiarTablicy++;
  23.                 l++;
  24.             }
  25.  
  26.             string[] podzielony = new string[rozmiarTablicy];
  27.  
  28.             for (int i = 0, j = 0; i < napis.Length; i++)
  29.             {
  30.                 if (napis[i] == delimeter)
  31.                 {
  32.                     string nowy = null;
  33.                     for (int k = pierwszaLitera; k < i; k++)
  34.                     {
  35.                         nowy += napis[k];
  36.                     }
  37.                     pierwszaLitera = i+1;
  38.                     podzielony[j] = nowy;
  39.                     j++;
  40.                 }
  41.             }
  42.  
  43.             return podzielony;
  44.  
  45.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement