chiva13

Untitled

Aug 28th, 2014
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <fstream>
  4. #include <string>
  5. using namespace std;
  6.  
  7. void print_lengths(std::string const& line)
  8. {
  9. unsigned int counter=0;
  10.  
  11. for (unsigned int i = 0; i < strlen(line.c_str()); i++)
  12. {
  13. if ( (line[i]!=' ') && (line[i]!='.') && (line[i]!='\n') )
  14. {
  15. cout<<line[i];
  16. counter++;
  17. }
  18. else
  19. {
  20. cout<<counter<<" ";
  21. counter=0;
  22. }
  23. }
  24. }
  25. int main()
  26. {
  27. //std::string string1;
  28. //std::ifstream ist("input.txt");
  29. //
  30. //while(ist.eof()==false)
  31. //{
  32. // std::getline (ist,string1);
  33. // std::cout << string1<<"\n";
  34. //}
  35.  
  36. print_lengths("aaa bbbb ccccc dddddd");
  37.  
  38.  
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment