• 统计 水NOJ 1599




    统计

    时间限制(普通/Java) : 1000 MS/ 3000 MS          运行内存限制 : 65536 KByte
    总提交 : 449            测试通过 : 135 

    题目描述

    编程统计一段文字中的英文字母和数字的数目

    输入

    输入一段文字,其中字符数不超过106

    输出

    在一行中依次输出英文字母、数字的数目,两种之间以一个空格分隔

    样例输入

        while (n!=1)
        {
            sum=sum+n;
            if (n % 2 == 1)
                n = n*3 +1;
            else n = n/2;
            count++;
        }
        printf(?%.3lf ", sum/count);
        return 0;

    样例输出

    52 8

    提示

     


    实现代码:

    #include<iostream>
    #include<stdlib.h>
    #include<stdio.h>
    #include<string.h>
    #include<math.h>
    using namespace std;
    int n=0,m=0;
    const int N=1000000+10;
    char a[N];
    int main()
    {
        char c;
      //  freopen("data.in","r",stdin);
        while((c=getchar())!=EOF)  
        {
            if(c>='0'&&c<='9')
            {
                ++m;
            }
            if((c>='A'&&c<='Z')||(c>='a'&&c<='z'))
            {
                ++n;
            }
        }
        printf("%d %d
    ",n,m);
    }

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    nginx负载均衡集群
    pureftp 服务
    LVS集群之DR模式 实现
    LVS集群之NAT模式实现
    resin 安装配置
    nfs部署和优化
    电压和电流有什么关系
    自动循环播放 播放器
    有趣的匿名方法
    使用匿名委托,Lambda简化多线程代码
  • 原文地址:https://www.cnblogs.com/Tobyuyu/p/4965559.html
Copyright © 2020-2023  润新知