标题:麻烦解释一下这道程序
取消只看楼主
cwzxwwy
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-4-9
结帖率:100%
已结贴  问题点数:10 回复次数:0 
麻烦解释一下这道程序
#include <iostream>
using namespace std;
int main()
{int upper=0,lower=0,digit=0,space=0,other=0,i=0;
char *p,s[200];
cout<<"input string:";
while ((s[i]=getchar())!='\n') i++;
p=&s[0];               
while (*p!='\n')
  {if (('A'<=*p) && (*p<='Z'))
     ++upper;
   else if (('a'<=*p) && (*p<='z'))
     ++lower;
   else if (*p==' ')
     ++space;
   else if ((*p<='9') && (*p>='0'))
     ++digit;
   else
     ++other;
   p++;
  }
cout<<"upper case:"<<upper<<endl<<"lower case:"<<lower<<endl;
cout<<"space:"<<space<<endl<<"digit:"<<digit<<endl<<"other:"<<other<<endl;
return 0;
}
搜索更多相关主题的帖子: include 
2012-05-16 11:56



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-367585-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.382598 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved