博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
1000. Letters and Words homework 12
阅读量:4657 次
发布时间:2019-06-09

本文共 541 字,大约阅读时间需要 1 分钟。

#include<iostream>

#include<sstream>
#include<cstring>
using namespace std;
int main(){
 char s[1000];
 string str;
 int count = 0;
 int count1 = 0;
    cin.get(s,1000,'\0');
    for(int i = 0; i < strlen(s); i++) {
  if((s[i] >= 'a' && s[i] <= 'z' ) || (s[i] >= 'A' && s[i] <= 'Z') || s[i] == ' ') count++;
 }
 for(int i = 0; i < strlen(s); i++) {
  if(s[i] == '\n') s[i] = ' ';
 }
 
 
 stringstream strs1(s);
 while(strs1>>str){
  count1++;
 }
 
 cout<<"Letters: "<<count<<endl;
 cout<<"Words: "<<count1<<endl;
 
}

转载于:https://www.cnblogs.com/sysu-eeman-yang/p/5987380.html

你可能感兴趣的文章
web渗透测试基本步骤
查看>>
使用Struts2标签遍历集合
查看>>
angular.isUndefined()
查看>>
第一次软件工程作业(改进版)
查看>>
网络流24题-飞行员配对方案问题
查看>>
引入css的四种方式
查看>>
iOS开发UI篇—transframe属性(形变)
查看>>
3月7日 ArrayList集合
查看>>
jsp 环境配置记录
查看>>
Python03
查看>>
LOJ 2537 「PKUWC2018」Minimax
查看>>
使用java中replaceAll方法替换字符串中的反斜杠
查看>>
Some configure
查看>>
流量调整和限流技术 【转载】
查看>>
1 线性空间
查看>>
VS不显示最近打开的项目
查看>>
DP(动态规划)
查看>>
chkconfig
查看>>
2.抽取代码(BaseActivity)
查看>>
夏天过去了, 姥爷推荐几套来自smashingmagzine的超棒秋天主题壁纸
查看>>