2382. Flowers Flourish from France
来源:互联网 发布:机房楼网络拓扑结构图 编辑:程序博客网 时间:2024/05/13 14:00
2382. Flowers Flourish from France
Constraints
Time Limit: 1 secs, Memory Limit: 256 MB
Description
Fiona has always loved poetry, and recently she discovered a fascinating poetical form. Tautograms are a special case of alliteration, which is the occurrence of the same letter at the beginning of adjacent words. In particular, a sentence is a tautogram if all of its words start with the same letter.
For instance, the following sentences are tautograms:
- Flowers Flourish from France
- Sam Simmonds speaks softly
- Peter pIckEd pePPers
- truly tautograms triumph
Fiona wants to dazzle her boyfriend with a romantic letter full of this kind of sentences. Please help Fiona to check if each sentence she wrote down is a tautogram or not.
Input
Each test case is given in a single line that contains a sentence. A sentence consists of a sequence of at most 50 words separated by single spaces. A word is a sequence of at most 20 contiguous uppercase and lowercase letters from the English alphabet. A word contains at least one letter and a sentence contains at least one word.
The last test case is followed by a line containing only a single character `
*
' (asterisk).Output
For each test case output a single line containing an uppercase `Y' if the sentence is a tautogram, or an uppercase `N' otherwise.
Sample Input
Flowers Flourish from France Sam Simmonds speaks softly Peter pIckEd pePPers truly tautograms triumph this is NOT a tautogram *
Sample Output
Y Y Y Y N
Problem Source
每周一赛第二场
#include <iostream>#include <string>#include <string.h>#include <stdio.h>#include <algorithm>#include <cctype>using namespace std;int main () {string a;while (getline(cin, a) && a != "*") {//toupper(a[0]);transform(a.begin(), a.end(), a.begin(), ::toupper);bool tmp = false; //标记前面一个是不是空格bool flag = true;for (int i = 1; i < a.size(); i++) {if (tmp == true) { //前面一个是空格if (a[i] != a[0]) { //和第一个不等//cout<<"false one : "<<a[i]<<endl;flag = false;break;} else {tmp = false;}}if (a[i] == ' ') {tmp = true;}if (flag == false)break;}if (flag == true)cout<<"Y"<<endl;elsecout<<"N"<<endl;}//system("pause");return 0;}
和vs势不两立!!!
0 0
- 2382. Flowers Flourish from France
- soj 2382. Flowers Flourish from France
- sicily 2382 Flowers Flourish from France
- UVa 12243 - Flowers Flourish from France
- flowers
- Flowers
- Flowers
- France '98
- hello! France
- barbour france
- 5 France
- uva542 - France '98
- 542 - France '98
- UVA 542 France '98
- UVa:542 France '98
- uva 542 France '98
- poj 3300 Tour de France
- HRBEU/HEUOJ----1059 France '98
- HttpUrlContext 简单实用2
- 常见的图片格式
- ant打war包,部署并运行
- Android菜鸟的成长笔记(17)—— 再看Android中的Unbounded Service
- 关于美术大家冯先生
- 2382. Flowers Flourish from France
- Python 面向对象编程(一)
- HDU 3313 Key Vertex (bfs)
- 面试题整理3 大数的表示及加减法问题
- HTML5中input为data型时不支持placeholder
- Esper处理嵌套POJO事件
- 线程之间的通信
- 博客搬家
- 《专业嵌入式软件开发》