23、给定程序MODI1.C中 fun 函数的功能是:分别统计字符串中大写字母和小写字母的个数。
例如, 给字符串 s 输入:AAaaBBb123CCccccd,则应输出结果:upper = 6, lower = 8。
请改正程序中的错误,使它能计算出正确的结果。
注意:不要改动 main 函数,不得增行或删行,也不得更改程序的结构!
#include /**********found**********/
void fun ( char *s, int a, int b )
{
while ( *s )
{ if ( *s >= 'A' && *s <= 'Z' )
/**********found**********/
*a=a+1 ;
if ( *s >= 'a' && *s <= 'z' )
/**********found**********/
*b=b+1;
s++;
}
}
main( )
{ char s[100]; int upper = 0, lower = 0 ;
printf( "\nPlease a string : " ); gets ( s );
fun ( s, & upper, &lower );
printf( "\n upper = %d lower = %d\n", upper, lower );
}
| 广告合作:400-664-0084 全国热线:400-664-0084 Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号 珠峰网 版权所有 All Rights Reserved
|