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;

    }

    //结果

  • 相关阅读:
    暑期测试训练3
    对于在线段树上修改整段区间的理解
    UVA 11090 判负圈问题
    ZOJ 2588 求割边问题
    POJ 1523 网络连通
    hdu 1163
    hdu 1703
    hdu 2577 模拟
    hdu 3836 强连通+缩点:加边构强连通
    hdu 2571
  • 原文地址:https://www.cnblogs.com/wanghong19991213/p/13591845.html
Copyright © 2011-2022 走看看