View Code of Problem 58

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include<math.h>
int main() {
    char str[1000];
    gets(str);
    int len = strlen(str);
    int n=0;
    for (int i = 0; i < len; i++) {
        if (str[i] != ' ' && str[i + 1] == ' ') {
            n++;
        }
        else if (str[i] != ' ' && str[i + 1] == '\0') {
            n++;
        }
    }
    printf("%d\n", n);
}

Double click to view unformatted code.


Back to problem 58