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方式提交正确:

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 网络电视连接失怎么办 网络电视没信号怎么办 转让店铺后悔了怎么办 蘑菇街没有流量怎么办 淘宝店没有生意怎么办 蘑菇街直播封号怎么办 淘宝忘记给赠品怎么办 直通车的占比高怎么办 赠品质量有问题怎么办 淘宝赠品有问题怎么办 顾客叫送赠品怎么办 淘宝展现量低怎么办 dw模板不更新怎么办 闭水试验漏水怎么办 绘声绘影试用过了怎么办 探探被选成试用新版用户怎么办 淘宝被限制评论怎么办 信用钱包套路了怎么办 农业银行还贷迟了一天怎么办 淘宝限购一件怎么办 小米盒子电视打不开怎么办 手机淘宝总是卡怎么办 淘宝相机不能用怎么办 作业盒子没声音怎么办 作业盒子闪退怎么办 双面羊绒缩水了怎么办 作业盒子为静音怎么办 没有上进心的人怎么办 孩子不听老人话怎么办 淘宝分销没有视频怎么办 孕妇血糖稍高怎么办 苹果6s 卡怎么办 花呗额度用完怎么办 手机百度网站无法访问怎么办 手机应用删不了怎么办 华为p4屏幕切换怎么办 手机搜不到设置怎么办 华为手机设置成怎么办 手机截屏模糊怎么办 图片上传不清晰怎么办 手机截屏不清楚怎么办