문장을 단어로 나누는 작업이 주어졌습니다. 여기에서는 문장에 있는 모든 단어를 분리합니다.
입력
I am a good boy
출력
I am a good boy
위의 예에서 우리는 한 줄에 한 단어를 인쇄할 것입니다.
예시
#include<iostream.h>
#include<string.h>
#include<stdio.h>
Using namespace std;
void split( string st){
String word = “ “;
for ( char s : st){
If (s== ‘ ‘){
Cout<< z << endl;
z = “ “;
}
else{
z = z = s;
}
}
Cout<< z <<endl;
}
Int main( ){
String st = “ Blood from heaven is mortal”;
Cout<< “Blood from heaven is mortal”;
Split(st);
return 0;
} 출력
위의 코드를 실행하면 다음 출력이 생성됩니다.
Blood from heaven is mortal Blood From Heaven is mortal
예시
#include
#include
#include
Using namespace std;
Void split( string st){
String word = “ “;
for ( char s : st){
If (s== ‘ ‘){
Cout<< z << endl;
z = “ “;
}
else{
z = z = s;
}
}
Cout<< z <<
}
int main( ){
String st = “ type a text message”;
Cout<< “type a text message”;
Split(st);
return 0;
} 출력
위의 코드를 실행하면 다음 출력이 생성됩니다.
type a text message type a text message