http://poj.org/problem?id=3157
Java vs C++
Time Limit:2000MS |
|
Memory Limit:65536K |
|
|
|
Description
Apologists of Java and C++ can argue for hours proving each other that their programming language is the best one. Java people will tell that their programs are clearer and less prone to errors, while C++ people will laugh at their inability to instantiate an array of generics or tell them that their programs are slow and have long source code.
Another issue that Java and C++ people could never agree on is identifier naming. In Java a multiword identifier is constructed in the following manner: the first word is written starting from the small letter, and the following ones are written starting from the capital letter, no separators are used. All other letters are small. Examples of a Java identifier arejavaIdentifier
,longAndMnemonicIdentifier
,name
,nEERC
.
Unlike them, C++ people use only small letters in their identifiers. To separate words they use underscore character ‘_
’. Examples of C++ identifiers arec_identifier
,long_and_mnemonic_identifier
,name
(you see that when there is just one word Java and C++ people agree),n_e_e_r_c
.
You are writing a translator that is intended to translate C++ programs to Java and vice versa. Of course, identifiers in the translated program must be formatted due to its language rules — otherwise people will never like your translator.
The first thing you would like to write is an identifier translation routine. Given an identifier, it would detect whether it is Java identifier or C++ identifier and translate it to another dialect. If it is neither, then your routine should report an error. Translation must preserve the order of words and must only change the case of letters and/or add/remove underscores.
Input
The input file consists of one line that contains an identifier. It consists of letters of the English alphabet and underscores. Its length does not exceed 100.
Output
If the input identifier is Java identifier, output its C++ version. If it is C++ identifier, output its Java version. If it is none, output “Error!
instead.
Sample Input
sample input #1
long_and_mnemonic_identifier
sample input #2
anotherExample
sample input #3
i
sample input #4
bad_Style
Sample Output
sample output #1
longAndMnemonicIdentifier
sample output #2
another_example
sample output #3
i
sample output #4
Error!
分享到:
相关推荐
北大POJ1016-Numbers That Count【字符串处理】 解题报告+AC代码
C + + language learning poj100 question bank and code
POJ 1328 java做!雷达问题!java版本!AC答案~
用java的biginteger实现的poj1001,比较简单的方法
NULL 博文链接:https://128kj.iteye.com/blog/1705139
poj上面的300道AC题,c++源码,自己写的不会有任何问题。
POJ1048,加强版的约瑟夫问题 难度中等
poj平台有关数据结构题的Java源码 1159 1276 2406 2502 2509 2513 2533 2778 3176
北大poj JAVA源码
动态规划 poj Common Subsequence c++ cpp文件
2、在中序遍历的字母串中找出 根字母,那么根字母左右两边的字符串就分别是它的左、右子树 3、利用递归复原二叉树(把子树看作新的二叉树) 4、后序遍历特征:后序遍历字母串 自右至左 依次为: 最外层(总树,设为...
北大 POJ的水题解答C++版,请合理使用
c++ npu poj答案100道全 请勿用于盈利
西北工业大学POJ试题C++答案代码+课程设计
pku acm 第3356题 AGTC Java代码,有详细的注释,动态规划
NULL 博文链接:https://128kj.iteye.com/blog/1749213
北大POJ2002-Squares 解题报告+AC代码
这是我个人写的POJ上2314题的Java实现,希望对喜欢ACM的人有帮助
NULL 博文链接:https://128kj.iteye.com/blog/1744222
这是北大(POJ)题库的代码,用C语言编译器编写,全部是AC的代码!