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 i = 0;
- //количество символов в строке
- while (str[i] != '\0'){
- i++;
- }
- char spc = ' ';
- int a, c = 0;
- int b = 0;
- for(a=0;a < i;a++){
- if (str[a] == spc){
- b++;
- }
- }
- int d = b + 1;
- //количество символов в строке
- cout << i << endl;
- //количество слов
- cout << d << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement