Цитата(Leno @ 7.1.2013, 11:54 ) | | В чем ошибка? |
до этой строки:
Цитата(Leno @ 7.1.2013, 11:54 ) | | word[j]= '\0'; // Нуль-симв |
всё правильно. дальше, простите, ерунда...
| Код | #include <iostream> using namespace std;
int main() { char s[256]; cout<<"Input a string:"<<endl; gets(s); int i = 0; char word[256]; while (s[i] != '\0') { // Пропуск не-букв while((s[i] != '\0') && ! isalpha(s[i])) i++; // Выделение слова int j =0; while((s[i] != '\0') && isalpha(s[i])) { word[j++] = s[i++]; } word[j]= '\0'; // Нуль-симв
bool sorted = true; for ( int i0 = 0, i1 = 1; word[ i0 ] && word[ i1 ]; i0++, i1++ ) { if ( word[ i1 ] - word[ i0 ] != 1 ) { sorted = false; break; } } if ( sorted ) { cout << word << endl; } } return 0; }
|
http://liveworkspace.org/code/2DLFA6$25 |