Untitled
unknown
plain_text
5 years ago
878 B
11
Indexable
#include<iostream>
#include<string>
using namespace std;
void input(string&);
int Separate(string);
void Output(int);
int main(){
string line; int count;
input(line);
count=Separate(line);
Output(count);
return 0;
}
void input(string& line){
cout<<"Please put 1 senterce :";
getline(cin, line, '/n');
}
int Separate(string line){
int len = line.length();
int countword = 0;
int countcharacter= 0;
for (int index=0; index<len; index++) {
if(line.at(index) != ' '){
countcharacter++;
cout<<line.at(index);
}
else{
cout<<endl;
countcharacter=0;
}
if (countcharacter==1)
countword++;
}
return countword;
}
void output(int count){
cout<<endl<<"Words count are "<<count<<endl;
}Editor is loading...