Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by registered user gorodetskiy ( 13 years ago )
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

bool Analys(string word)
{
 for (int i = 0; i < word.length() - 1; i++)
 {
  if (!(word[i] <= word[i + 1]))
   return false;
 }
 return true;
}

int _tmain(int argc, _TCHAR* argv[])
{
 string str = "";
 cout<<"Type the string: "; getline(cin, str);

 string temp = "";
 string spaces = "";
 for (int i = 0; i < str.length(); i++)
 {
  string word = "";
  if (str[i] == ' ') spaces += str[i];
  while ((str[i] != ' ') && (i != str.length()))
  {
   word += str[i];
   i++;
  }
  if (word != "") 
   if (Analys(word)) temp += spaces + word;
  
 }
 str = temp;
 cout<<"Result: "<<str<<endl;

 return 0;
}

 

Revise this Paste

Your Name: Code Language: