Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. using System;
  2.  
  3. namespace test
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string value = "123456721332123312123";
  10.  
  11. int kolkoChastiIksashDaIma = 11;
  12.  
  13. int lenghtOfValue = value.Length;
  14. int firstIndexLemgth = lenghtOfValue / kolkoChastiIksashDaIma;
  15.  
  16. int oneLenght = lenghtOfValue / kolkoChastiIksashDaIma;
  17. int lastIndexLenght = oneLenght + firstIndexLemgth;
  18.  
  19. string newStr = "";
  20.  
  21.  
  22. int counter = 1;
  23. for (int i = 0; i < lenghtOfValue; i++)
  24. {
  25. if (counter == kolkoChastiIksashDaIma)
  26. {
  27. newStr += value[i];
  28. continue;
  29. }
  30. if (i==0)
  31. {
  32. newStr += value[i];
  33. continue;
  34. }
  35. if(i%firstIndexLemgth==0)
  36. {
  37.  
  38. newStr +=" ";
  39. counter++;
  40.  
  41. }
  42. newStr += value[i];
  43. }
  44. Console.WriteLine(newStr);
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement