/*
请编程实现:由键盘输入的任意一组字符,统计其中大写字母的个数m和小写字母的个数n,并输出m、n中的较大者。
*/
echo maxZimu("ajmkKRHGSPnmlzcx");
function maxZimu($str)
{
$str_dx="";
$str_xx="";
for($i=0;$i<strlen($str);$i++)
{
$single=substr($str,$i,1);
if(ord($single)<97)
{
echo $single.ord($single)." 1<br>";
if($str_dx<>"")
{
if(ord($single)>ord($str_xx))
{
$str_dx=$single;
}
}
else
{
$str_dx=$single;
}
}
else
{
echo $single.ord($single)." 2<br>";
if($str_xx<>"" )
{
if(ord($single)>ord($str_xx))
{
$str_xx=$single;
}
}
else
{
$str_xx=$single;
}
}
}
echo $str."字符串中大写字符是".$str_dx."小写字符是".$str_xx;
}
请编程实现:由键盘输入的任意一组字符,统计其中大写字母的个数m和小写字母的个数n,并输出m、n中的较大者。
*/
echo maxZimu("ajmkKRHGSPnmlzcx");
function maxZimu($str)
{
$str_dx="";
$str_xx="";
for($i=0;$i<strlen($str);$i++)
{
$single=substr($str,$i,1);
if(ord($single)<97)
{
echo $single.ord($single)." 1<br>";
if($str_dx<>"")
{
if(ord($single)>ord($str_xx))
{
$str_dx=$single;
}
}
else
{
$str_dx=$single;
}
}
else
{
echo $single.ord($single)." 2<br>";
if($str_xx<>"" )
{
if(ord($single)>ord($str_xx))
{
$str_xx=$single;
}
}
else
{
$str_xx=$single;
}
}
}
echo $str."字符串中大写字符是".$str_dx."小写字符是".$str_xx;
}