Главная » 2016 » Апрель » 5 » строки - количество слов
08:59
строки - количество слов

#include <iostream>
using namespace std;
void vvod(char *ch)
{
    gets(ch);
}
void vivod(char *ch)
{
    cout<<ch<<endl;
}
int KolvoWords(char *ch)
{
    int i=0, kolvo=0;
    while (i<strlen(ch))
    {
        while ((ch[i]==' ')&&(i<strlen(ch)))
            i++;
        while ((ch[i]!=' ')&&(i<strlen(ch)))
            i++;
        i++; 
        kolvo++;
    }
    return kolvo;
}
int main()
{
    setlocale(LC_ALL,"rus_rus.1251");
    char str1[80];
    vvod(str1);
    vivod(str1);
    cout<<"Количество слов в строке = "<< KolvoWords(str1)<<endl;

    system("pause");
    return 0;
}

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