Advertisement
moseskarunia

Format Input & Output

Mar 30th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. string rawNames = "Hasan@David@Siti@Malvin@Iven"
  2. string[] splittedNames;
  3.  
  4. int atCounter = 0;
  5. for(int i = 0 ; i < rawNames.length ; i++)
  6. {
  7. if(rawNames[i] == '@')
  8. {
  9. atCounter++;
  10. }
  11. }
  12.  
  13. splittedNames = new string[atCounter + 1];
  14.  
  15. int currentIndex = 0;
  16. for(int i = 0 ; i < rawNames.length ; i++)
  17. {
  18. if(rawNames[i] != '@')
  19. {
  20. splittedNames[currentIndex] += rawNames[i];
  21. }
  22. else
  23. {
  24. currentIndex++;
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement