View Code of Problem 58

//
//  main.c
//  a
//
//  Created by rex on 16/9/14.
//  Copyright © 2016年 rex. All rights reserved.
//

#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
    char str[100], prev;
    int res = 0;
    gets(str);
    for(int i=0; i<strlen(str); i++) {
        if(str[i] != prev && (isblank(prev) || i == 0) ) {
            res++;
        }
        prev = str[i];
    }
    printf("%d\n", res);
    return 0;
}

Double click to view unformatted code.


Back to problem 58