A1343 | [COCI-2016_2017-contest3]#1 Imena
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Little Mirko likes to type and often gets bored during class, which is why his teacher assigned him a task.
Mirko must retype a book that contains N space-separated sentences. In this book, a sentence is an array of one or more space-separated words, where only the last word’s character is a punctuation mark ( '.', '?' or '!' ). The rest of the words do not contain punctuation marks.
Words are arrays of characters, either lowercase or uppercase letters of the English alphabet, or digits or, exceptionally, a punctuation mark at the end of the last word in the sentence.
Although he likes typing sentences, Mirko doesn’t like typing names. A name is a word that starts with an uppercase letter of the English alphabet, whereas the rest of the characters are lowercase letters of the English alphabet, except the last character, which can be the punctuation mark. Before he decides to retype the whole thing, Mirko wants to know how many names there are in each sentence of the book. Write a programme to help him!
Mirko must retype a book that contains N space-separated sentences. In this book, a sentence is an array of one or more space-separated words, where only the last word’s character is a punctuation mark ( '.', '?' or '!' ). The rest of the words do not contain punctuation marks.
Words are arrays of characters, either lowercase or uppercase letters of the English alphabet, or digits or, exceptionally, a punctuation mark at the end of the last word in the sentence.
Although he likes typing sentences, Mirko doesn’t like typing names. A name is a word that starts with an uppercase letter of the English alphabet, whereas the rest of the characters are lowercase letters of the English alphabet, except the last character, which can be the punctuation mark. Before he decides to retype the whole thing, Mirko wants to know how many names there are in each sentence of the book. Write a programme to help him!
输入格式
The first line of input contains the integer N (1 ≤ N ≤ 5), the number from the task.
The second line contains N sentences from the book. The total number of characters in the book will not exceed 100
0.
The second line contains N sentences from the book. The total number of characters in the book will not exceed 100
0.
输出格式
You must output N lines. The i^th line contains the number of names in the i^th sentence.
输入输出样例
输入 #1
1
输出 #1
4
输入 #2
2
输出 #2
1 2
In test cases worth 40 points total, it will hold N = 1.
Clarification of the second test case:
The word “An4” starts with an uppercase letter, but contains a digit and therefore can’t be a name.
Clarification of the second test case:
The word “An4” starts with an uppercase letter, but contains a digit and therefore can’t be a name.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted