zoukankan      html  css  js  c++  java
  • 判断字符串类型

    1199 判断字符串类型

    题目描述

    输入一个字符串,其中只能包括数字或字母。对应输入的字符串,输出它的类型。如果是仅由数字构成的那么输出digit,如果是仅由字母构成的那么输出character,如果是由数字和字母一起构成的输出mixed。

    输入描述

    /*
    输入一个字符串,长度不超过1000,且字符串中只包括数字或大、小写字母。
    */
    Sun2009
    

    输出描述

    /*
    输出对应的类型。
    */
    mixed
    
    #include<stdio.h>
    #include<string.h>
    
    void judgetype(char s[]){
        int i=0;
        int numflag = 0;
        int charflag = 0;
        int len = strlen(s);
        for(i=0;i<len;i++){
            if(s[i]>='0' && s[i]<= '9')
                numflag = 1;
            else if(s[i]>='A' && s[i]<= 'z')
                charflag = 1;
        }
        if(numflag && charflag)
            printf("mixed
    ");
        else if(charflag && !numflag)
            printf("character
    ");
        else if(numflag && !charflag)
            printf("digit
    ");
    }
    
    int main()
    {
        char s[1000];
        scanf("%s",s);
        judgetype(s);
        return 0;
    }
    
  • 相关阅读:
    Python import模块
    Python 内置函数
    Python Pickle序列化
    android xml布局文件属性说明
    android 中动画
    Android样式——Styles
    代码家
    Android UI目录
    Android 基本控件
    android and webview 网页应用
  • 原文地址:https://www.cnblogs.com/lwp-nicol/p/14285189.html
Copyright © 2011-2022 走看看