zoukankan      html  css  js  c++  java
  • 用ASCLL判断输入元素

    数字0-9的ASCII码为:048到057
    大写字母A-Z的ASCII为:065-090
    小写字母a-z的ASCII为:097到122

    判断字符是数字还是大小写字母

    int main()
    
    {
    
            input=getchar();//获取输入的字符
            if(input <= 32)
                    printf("You have input a control  character!!
    ");
            else if(input >= 48 && input <= 57)    //数字;
            {
                    for( i=48;i<58;i++)
                    {
                            if(input==i)
                                    break;
                    }
                    printf("You put a number,ranging from 0--9!
     The number is %d!
     ",i);
            }
            else if(input >=65 && input <=90 )  //大写字母;
            {
                    for( i=65; i<=90; i++)
                    {
                            if(input==i)
                                    break;
                    }
                    printf("You have put a uppercase! Ranging from A--Z!
    The number is %d!
    ",i);
            }
            else if(input >=97 && input <=122)   //小写字母
            {
                    for( i=97;i<=122;i++)
                    {
                            if(i==input)
                                    break;
                    }
                    printf("You have input a lowercase! Ranging from a--z!
    The number is %d
    ",i);
            }
            else  
                    printf("You have input a other character!
    ");
            }
  • 相关阅读:
    ●表单元素
    ●HTML网页标签2
    ●数据库的备份
    ●HTML网页标签1
    ●索引、视图、游标
    ●SQL编程
    ●关系数据库基础
    ●常用函数
    ●SQL练习题
    ●SQL高级查询
  • 原文地址:https://www.cnblogs.com/zyqx/p/9455968.html
Copyright © 2011-2022 走看看