FZU 1840 Lexical translator for Java and C++
来源:互联网 发布:师洋淘宝 编辑:程序博客网 时间:2024/05/01 02:47
Lexical translator for Java and C++
Time Limit:1sMemory limit:32MAccepted Submit:11Total Submit:38
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 are javaIdentifier
, longAndMnemonicIdentifier
, name
, OpenSolaris
.
Unlike them, C++ people use only small letters in their identifiers. To separate words they use underscore character ‘_
’. Examples of C++ identifiers are c_identifier
, long_and_mnemonic_identifier
, name
(you see that when there is just one word Java and C++ people agree), open_solaris
.
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 multiply testcases. For each testcase, there is 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 “Unknown!
instead.
Sample Input
long_and_mnemonic_identifieranotherExampleibad_Style
sample output
longAndMnemonicIdentifieranother_exampleiUnknown!
Original: Funny Programming Contest -- OSUM
解题:
分三种情况:
1. Java语言
2. C++语言
3. 非语言情况(下划线后面不是大写字母;首字母为大写字母)
以下代码vc方式提交正确:
- FZU 1840 Lexical translator for Java and C++
- difirence for java php and js and c and python
- Lexical scope and function closures in R
- QEMU, a Fast and Portable Dynamic Translator
- QEMU, a Fast and Portable Dynamic Translator
- JAVA语言词法(lexical)--正则表达式描述
- eclipse for c, cpp and java in Ubuntu
- Introduction to SIP for Java, C#, and VB Developers
- 单例模式 for java and object-c
- 静态代码分析工具-jenkins应用(checkstyle and findbugs for java,cccc and cppcheck for c/c++)
- ICE Manual(Documentation for Ice 3.5)---Slice Lexical Rules
- C Reference Manual Reading Notes: 009 Preprocessor Lexical Conventions
- MAT: A Multimodal Attentive Translator for Image Captioning
- C and C Complier Quickstart for Unix
- Java语言系列02——Lexical Grammar (词法)介绍
- continue and break for java
- java Iterable and for each
- fzu月赛--C(fzu 2177)
- domino 8.5: XML Java ,Xpage
- Intel Moblin将正式整合到Fedora 12
- 如何制作GHOST启动盘
- 绝对悲剧の连接错误(调了一个星期)
- 常用SQL语句技法
- FZU 1840 Lexical translator for Java and C++
- SQL Server 2000中的触发器使用
- ROLLUP和CUBE
- Java或C#调用命令行批处理命令如何获得返回值
- MySQL 常用命令
- 易出错问题汇总
- 独家:Java 7新特性及简单性能对比测试
- 在Java中实现浮点数的精确计算
- 满堆栈与空堆栈