1000. Letters and Words homework 12

#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;
 
}

时间: 2024-08-26 18:10:35

1000. Letters and Words homework 12的相关文章

1000.1 Letters and Words homework 12

#include <iostream> #include <iomanip> #include <cmath> using namespace std; //your code will be hereclass Land { public: Land() : price_(0) {} explicit Land(int price); // calculate how much Feng Gor can earn from the land virtual doubl

hdu1789Doing Homework again(贪心)

题目链接: 啊哈哈,点我点我 思路: 这道题是简单的贪心..先按分数从大到小排序,然后将这个分数的截止日期从后向前扫描,如果碰到没有被标记的则这一天可以做这个作业... 题目: Doing Homework again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 6451    Accepted Submission(s): 383

12!配对

题目要求: 输入代码: #include<iostream> #include<stdio.h> using namespace std; int main() { long i,j,k=0,s=1; long a[1000]; for(i=1;i<=12;i++)//初始化12的阶乘结果 { s*=i; } i=0; while(scanf("%ld",&a[i])!=EOF)//输入多少元素就保存多少,必须以Ctrl+Z终止循环以得出结果,延续

To and Fro(字符串水题)

To and Fro 点我 Problem Description Mo and Larry have devised a way of encrypting messages. They first decide secretly on the number of columns and write the message (letters only) down the columns, padding with extra random letters so as to make a rec

POJ3294--Life Forms 后缀数组+二分答案 大于k个字符串的最长公共子串

Life Forms Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 10800   Accepted: 2967 Description You may have wondered why most extraterrestrial life forms resemble humans, differing by superficial traits such as height, colour, wrinkles, e

字符串(后缀数组):POJ 3294 Life Forms

Life Forms Description You may have wondered why most extraterrestrial life forms resemble humans, differing by superficial traits such as height, colour, wrinkles, ears, eyebrows and the like. A few bear no human resemblance; these typically have ge

C#多线程和异步(三)——一些异步编程模式

一.任务并行库 任务并行库(Task Parellel Library)是BCL中的一个类库,极大地简化了并行编程,这里以Parallel.For和Parallel.ForEach为例.在C#中for/foreach循环使用十分普遍,如果迭代不依赖与上次迭代的结果时,把迭代放在 不同的处理器上并行处理 将很大地提高运行效率,Parallel.For和Parallel.ForEach就是为这个目的而设计的. 一个栗子: 1 static void Main(string[] args) 2 { 3

POJ 3294 Life Forms [最长公共子串加强版 后缀数组 &amp;&amp; 二分]

题目:http://poj.org/problem?id=3294 Life Forms Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 18549   Accepted: 5454 Description You may have wondered why most extraterrestrial life forms resemble humans, differing by superficial traits s

【HDU 3294】Life Forms

Description You may have wondered why most extraterrestrial life forms resemble humans, differing by superficial traits such as height, colour, wrinkles, ears, eyebrows and the like. A few bear no human resemblance; these typically have geometric or