zoukankan      html  css  js  c++  java
  • 非空格字符串个数

    #define _CRT_SECURE_NO_WARNINGS
    #include<stdio.h>
    #include<string.h>
    #include<stdlib.h>
    #include<math.h>
    #include<time.h>

    int getstrcount01(char*ch)

    {

      int i=0;

      int count=0;

      while(ch[i])

      {

        if(ch[i]!='  ')

        {

          count++;

        }

        i++;

      }

      return count;

    }

    int getstrcount(char*ch)

    {

      int count =0;

      while(*ch)

      {

        if(*ch!=32)count++;

        ch++;

      }

      return count;

    }

    int main0101()

    {

      //非空格字符串个数

      char ch[] = "    hello world   ";

      int len=getstrcount(ch);

      printf("%d ",len);

      return EXIT_SUCCESS;

    }

    int main(void)

    {

    //统计字符出现次数

      char ch[] = "helloworldnichoushachounizadizaichouyigeshishi";

    //存储字符串出现次数

      int arr[26]={0};

      for(int i=0;i<strlen(ch);i++);

      {

        arr[ch[i]-'a']++;

      }

      for(int i=0;i<26;i++)

      {

        if(arr[i])

        printf("字母%c出现次数:%d ",i+'a',arr[i]);

      }

      return 0;

    }

    //结果

  • 相关阅读:
    表格的增删改查
    选择省份时,自动显示对应省份的城市
    弹框提示用户输入
    dom
    css基础
    HTML基础
    B
    poj 1840 Eqs
    hdu 1166 敌兵布阵(线段树)
    poj 2586 Y2K Accounting Bug
  • 原文地址:https://www.cnblogs.com/wanghong19991213/p/13591845.html
Copyright © 2011-2022 走看看