Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main(){
- setlocale(LC_ALL, "Russian");
- cout << "Введите предложение: ";
- char str[100];
- cin.getline(str, 100);
- int j, words, i = 0;
- //количество символов в строке
- while (str[i] != '\0'){
- i++;
- }
- int spc = 32;
- words = 0;
- int k;
- int b = 0;
- for(j = 1;j < i; j++){
- for(k=128;256>k;k++){
- if (str[j] == char(k)){
- if(str[b] != char(spc)){
- words++;
- }
- }
- }
- k = 128;
- }
- words = i - words;
- //количество символов в строке
- cout << i << endl;
- //количество слов
- cout << words << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement