zoukankan      html  css  js  c++  java
  • 嗯!如此统计文章字符类型和个数

    #include <iostream>
    using namespace std;
    int main()
    {int i,j=0,A=0,b=0,data=0,other=0,space=0;
     char a[3][80];
     for(i=0;i<3;i++)
     {  cin>>a[i];
        for(j=0;j<80,a[i][j]!='\0';j++)
      {if(a[i][j]>='A'&&a[i][j]<='Z')
        A++;
           else  if(a[i][j]>='a'&&a[i][j]<='z')
         b++;
            else  if(a[i][j]>='0'&&a[i][j]<='9')
          data++;
             else  if(a[i][j]=='')
           space++;
            else
             other++;
      }
     }
     cout<<"big char:"<<A<<endl;
     cout<<"little char:"<<b<<endl;
     cout<<"data:"<<data<<endl;
     cout<<"space:"<<space<<endl;
     cout<<"others:"<<other<<endl;
     return 0;
    }


    #include <iostream>
    using namespace std;
    int main()
    {int i,j=0,A=0,b=0,data=0,other=0,space=0;
     char a[3][80];
     for(i=0;i<3;i++)
     { gets(a[i]);                             //gets与cin有所不同
        for(j=0;j<80,a[i][j]!='\0';j++)
      {if(a[i][j]>='A'&&a[i][j]<='Z')
        A++;
           else  if(a[i][j]>='a'&&a[i][j]<='z')
         b++;
            else  if(a[i][j]>='0'&&a[i][j]<='9')
          data++;
             else  if(a[i][j]==' ')
           space++;
            else
             other++;
      }
     }
     cout<<"big char:"<<A<<endl;
     cout<<"little char:"<<b<<endl;
     cout<<"data:"<<data<<endl;
     cout<<"space:"<<space<<endl;
     cout<<"others:"<<other<<endl;
     return 0;

  • 相关阅读:
    DateUtil(比较两个日期是否是同一天)
    用过的读写
    小笔记
    日志解析LogParse启动参数配置
    wow经典台词
    Quartz资源收藏
    Quartz Job基本示例
    已知两点坐标,及在从其中一点开始移动的距离,求移动到的坐标
    如何为SUSE配置IP地址,网关和DNS
    详解Linux Initrd
  • 原文地址:https://www.cnblogs.com/zhangdashuai/p/3702196.html
Copyright © 2011-2022 走看看