Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <fstream>
- #include <string>
- using namespace std;
- void print_lengths(std::string const& line)
- {
- unsigned int counter=0;
- for (unsigned int i = 0; i < strlen(line.c_str()); i++)
- {
- if ( (line[i]!=' ') && (line[i]!='.') && (line[i]!='\n') )
- {
- cout<<line[i];
- counter++;
- }
- else
- {
- cout<<counter<<" ";
- counter=0;
- }
- }
- }
- int main()
- {
- //std::string string1;
- //std::ifstream ist("input.txt");
- //
- //while(ist.eof()==false)
- //{
- // std::getline (ist,string1);
- // std::cout << string1<<"\n";
- //}
- print_lengths("aaa bbbb ccccc dddddd");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment