Guest User

Untitled

a guest
Nov 22nd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream>
  2. //#include <stdlib.h>
  3. //#include <stdio.h>
  4. using namespace std;
  5.  
  6. void collectors(char *str, int n) {
  7. for(int i = 0; i < n; i++) {
  8. if(str[i] != ' ') {
  9. break;
  10. }
  11.  
  12. if(str[i] == ' ') {
  13. int k = 0;
  14. for(int i = 0; str[i] == ' '; i++) {
  15. if(str[i] == ' ') {
  16. k++;
  17. }
  18. }
  19. for(int i = 0; i < n; i++) {
  20. str[i] = str[i + k];
  21. }
  22. }
  23. }
  24.  
  25. cout << "Result:" << str << endl;
  26. }
  27.  
  28. int main()
  29. {
  30. const int n = 999;
  31. char str[n];
  32. int i;
  33. cout << "Enter string:";
  34. //gets(str);
  35. cin.get(str, n);
  36. cout << "Entered string:" << str << "\n";
  37.  
  38. collectors(str, n);
  39. }
Add Comment
Please, Sign In to add comment