Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. void Nword(char* initialString, int position)
  4. {
  5. if (position == 0)
  6. {
  7. std::cout << -1;
  8. return;
  9. }
  10. else if (position == 1)
  11. {
  12. while (*initialString != ' ')
  13. {
  14. //initialString = initialString + 1;
  15. std::cout << *initialString;
  16. if (*initialString != '\0')
  17. initialString = initialString + 1;
  18. else return;
  19. }
  20. return;
  21. }
  22. else
  23. {
  24. if (*initialString == ' ')
  25. return Nword(initialString + 1, position - 1);
  26. else
  27. {
  28. return Nword(initialString + 1, position);
  29. }
  30. }
  31. }
  32. int main()
  33. {
  34. char a[] = "asadf fadf sdfs gfusdhh";
  35. int b;
  36. std::cin >> b;
  37. Nword(a, b);
  38. return 0;
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement