| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 327 人关注过本帖
标题:麻烦解释一下这道程序
只看楼主 加入收藏
cwzxwwy
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-4-9
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:2 
麻烦解释一下这道程序
#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
yuccn
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:何方
等 级:版主
威 望:167
帖 子:6815
专家分:42393
注 册:2010-12-16
收藏
得分:7 
cout<<"upper case:"<<upper<<endl<<"lower case:"<<lower<<endl;
 cout<<"space:"<<space<<endl<<"digit:"<<digit<<endl<<"other:"<<other<<endl;
 
如果这个信息给你,你都要人家帮你解析这个函数,你就要好好反省一下了。

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2012-05-19 11:50
邋遢鬼
Rank: 2
等 级:论坛游民
帖 子:29
专家分:94
注 册:2011-5-29
收藏
得分:0 
统计输入的字符串中数字,大写字母,小写字母,空格,以及别的比如标点等的个数。
2012-05-30 11:22
快速回复:麻烦解释一下这道程序
数据加载中...
 
   



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

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