• 嗯!如此统计文章字符类型和个数


    #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;

  • 相关阅读:
    解决配置Windows Update失败问题
    Rabbit MQ 消息确认和持久化机制
    Spring Boot事务管理(上)
    Spring Boot事务管理(中)
    Spring Boot事务管理(下)
    接口和抽象类的区别
    MySQL索引优化
    Spring 注解之@RestController与@Controller的区别
    Spring Boot核心注解@SpringBootApplication
    Java抽象类与接口的区别
  • 原文地址:https://www.cnblogs.com/zhangdashuai/p/3702196.html
Copyright © 2020-2023  润新知