Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- void spaceCount(string, int*);
- void showWords(string[],int);
- int main(){
- string fullString;
- int fSpace = 0, point = 0, each = 0, pos, indef = 0, numb = 0;
- cout << "type a sentense :\n";
- getline(cin,fullString);
- fullString += ' ';
- spaceCount(fullString,&fSpace);
- string *words = new string[fSpace];
- do {
- pos = fullString.find(" ");
- words[each] = fullString.substr(point, pos);
- fullString.erase(point, pos + 1);
- each++;
- } while (!fullString.empty());
- for (int i = 0; i < each-1; i++){
- for (int j = i + 1; j < each; j++){
- if (words[i] == words[j]){
- words[i].clear();
- words[j].clear();
- indef++;
- }
- }
- }
- for (int k = 0; k < each; k++){
- for (int i = 0; i < words[k].length(); i++){
- for (int j = i + 1; j < words[k].length(); j++){
- if (words[k].at(i) == words[k].at(j)){
- words[k].at(j) = 0;
- words[k].at(i) = 0;
- }
- }
- }
- }
- showWords(words, each);
- delete []words;
- system("pause");
- return 0;
- }
- void spaceCount(string currString,int *space){
- for (int i = 0; i < currString.length(); i++){
- if (currString.at(i) == ' ')
- *space += 1;
- }
- }
- void showWords(string word[],int eac){
- for (int i = 0; i < eac; i++)
- cout << word[i] << " ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement