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;

  • 相关阅读:
    着迷英语900句总结
    SQL Server 常见数据类型
    SQL Server视频总结
    第三次SLA文档学习
    Rosetton Stone Summary
    【周总结】2018-10-19—2018-11-25
    学生信息管理系统总结
    VB中 EOF 和 BOF 的区别
    VB中 On error 的用法
    VB中 . 与 ! 的区别
  • 原文地址:https://www.cnblogs.com/zhangdashuai/p/3702196.html
Copyright © 2011-2022 走看看