zoukankan      html  css  js  c++  java
  • 定义指针函数,输入字符串求其中的字母、数字和其它字符的个数

    1. #include "stdio.h"  
    2. #define M 1000  // 宏定义字节最大长度  
    3. int character = 0, num = 0, other = 0;  
    4.   
    5. int f(char *x)  
    6. {  
    7. int i = 0;  
    8.   
    9.   
    10. for ( i = 0; *(x+i) != ''; i++)  
    11. {  
    12. if (( *( x + i ) >= 'a' && *( x + i) <= 'z') || (*( x + i ) >= 'A' && *( x + i) <= 'Z'))//字母个数  
    13. character++;  
    14. else if ( *( x + i ) >= '0' && *( x + i) <= '9')//数字个数  
    15. num++;  
    16. else  
    17. other++;//其它字符个数  
    18. }  
    19.   
    20. printf ("The character is:%d ", character );  
    21. printf ("The number is:%d ", num );  
    22. printf ("Other is:%d ", other );  
    23.   
    24. return ( word, num, other);  
    25. }  
    26.  main()  
    27. {  
    28.   
    29.  char ch[M];  
    30.   
    31. printf ("请输入你要求的字符串 ");  
    32. gets(ch);//字符串的输入  
    33.   
    34. f(ch);//函数的调用  
    35.   
    36. }  
  • 相关阅读:
    FSL
    64位MicrosoftOfficeWord加载EndnoteX7
    Lobes of the brain
    Anterior and posterior commissures
    Broadmann area (wiki)
    Broadmann分区
    matlab FDR校正
    AI图片剪切
    DPABI advanced edition 文件夹组织形式
    Frequently Asked Questions
  • 原文地址:https://www.cnblogs.com/haichun/p/3508805.html
Copyright © 2011-2022 走看看