zoukankan      html  css  js  c++  java
  • c语言实现wc功能

    本随笔对网站http://blog.chinaunix.net/uid-22566367-id-381958.html有所借鉴

    #include <stdio.h>


    #define BEGIN 1;

    int main(int argc, char *argv[])
    {
        int characters, lines, words, state;
        char c;

        state = characters = lines = words = 0;
        while((c = getchar()) != '0') {
            characters++;
            if(c == ' ') {
                lines++;
                state = 0;
                continue;
            } else if(c == ' ') {
                state = 0;
                continue;
            } else if(c == ' ') {
                state = 0;
                continue;
            } else {
                if(state == 0) {
                    state = BEGIN;
                    words++;
                }
                continue;
            }
        }

        printf("%d characters. %d words. %d lines. ", characters, words, lines);
    }

  • 相关阅读:
    redis 数据类型 Hash
    redis有序集合类型sort set
    redis数据类型set
    redis的 list
    redis的key
    centos安装redis
    input聚焦事件
    width(),innerWidth(),outerWidth(),outerWidth(true)
    jq 选择器
    详解CSS中:nth-child的用法_大前端
  • 原文地址:https://www.cnblogs.com/vonzc/p/7609153.html
Copyright © 2011-2022 走看看