Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdlib>
- using namespace std;
- string ns;
- strRemove(string s)
- {
- for(int i =0; i<s.length(); i++){
- if(s.at(i)!=' ')
- {
- ns+=s.at(i);
- }
- }
- }
- stringSpace(string inputString, int spaceNumber)
- {
- int found = -1;
- int lookedSpace = 0;
- int counter = 0;
- do
- {
- found = inputString.find(" ", found+1);
- if(found!=-1)
- {
- lookedSpace = found;
- counter++;
- }
- }
- // while(found<=words.length()-15);
- while(counter<spaceNumber);
- return lookedSpace;
- }
- primeNumberCheck(int n) {
- int i, m=0, flag=0;
- //cout << "Enter the Number to check Prime: ";
- // cin >> n;
- m=n/2;
- for(i = 2; i <= m; i++)
- {
- if(n % i == 0)
- {
- cout<<"Number is not Prime."<<endl;
- flag=1;
- break;
- }
- }
- if (flag==0)
- cout << "Number is Prime."<<endl;
- return 0;
- }
- int main()
- {
- string words = "one two three four five six";
- string word = "zero";
- /* int found = -1;
- int lastSpace = 0;
- int counter = 0;
- do
- {
- found = words.find(" ", found+1);
- if(found!=-1)
- {
- lastSpace = found;
- counter++;
- }
- }
- // while(found<=words.length()-15);
- while(counter<2);
- */
- //words = words.substr(0,found) + " "+ word +words.substr(found);
- //words = words.substr(0,lastSpace) + " "+ word +words.substr(lastSpace);
- primeNumberCheck(10);
- int spaceFound = stringSpace(words,1);
- // int spaceFound1 = stringSpace(words,1);
- //int spaceFound2 = stringSpace(words,3);
- words = words.substr(0,spaceFound);
- strRemove(words);
- string outputString = ns; // The string from STR REMOVE
- //words = words.substr(spaceFound1,spaceFound2);
- cout << outputString;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement