Главная » 2017 » Март » 20 » строка. разделить на слова
10:28
строка. разделить на слова

#include<iostream>
using namespace std;
int main()
{
    setlocale(LC_ALL, "Russian");
    char st[80], slovo[20];
    cout<<"Vvedite stroku"<<endl;
    gets(st);
    int i=0,j;
    while (st[i])
    {
        //пропуск пробелов
        while ((st[i]==' ')&&(st[i])) 
            i++;
        //формирование нового слова
        j=0;
        while ((st[i]!=' ')&&(st[i]))
        {
            slovo[j]=st[i];
            i++;
            j++;
        }
        slovo[j]='\0';
        cout<<slovo<<endl;
    }

    system("pause");
    return 0;
}

Просмотров: 591 | Добавил: denjes | Рейтинг: 0.0/0
Всего комментариев: 0
avatar