C + + and Java (analog)

Source: Internet
Author: User
Tags uppercase letter

C + + and JavaTime Limit: 1000MS Memory Limit:65536KB 64bit IO Format:%lld &%llu< /c11>

Description

According to the Java naming convention, the naming convention for variable names consisting of multiple words is: The first word begins with a lowercase letter, the remaining words begin with an uppercase letter, and the words do not have any separators between the words, except for the letters with the first letter of the word being lowercase. For example: Name, MyName. C + + is named with all lowercase letters, and "_" is used between words and words as delimiters. For example: Name, My_name.
Your job is to write a program that converts the name of a variable named by C + + to a Java naming method.

Input

The input contains multiple sets of test data.

Each set of data is a row of strings (the string length does not exceed 100).

Output

For each set of test data, output the converted string. Note: If the input string does not conform to the C + + naming convention, output "Error" (without quotation marks).

Sample Input

My_namemyname

Sample Output

Mynameerror

#include <stdio.h>#include<string.h>#include<string.h>intMain () {Chars[ +], t[ +]; intLen, I, K, flag;  while(Gets (s)! =NULL) {k=0; Flag=0; memset (T,0,sizeof(t)); Len=strlen (s);  for(i=0; i<len; i++)//whether to name a legitimate C + +        {            if(s[i]<'a'|| S[i]>'Z')            {                if(s[i]=='_')                {                    if(s[0]=='_'|| s[len-1]=='_'|| s[i+1]=='_') {printf ("error\n"); Flag=1;  Break; }                }                Else{printf ("error\n"); Flag=1;  Break; }            }        }        if(flag)Continue;  for(i=0; i<len; i++)//if the legal changes to the Java naming form        {            if(s[i]=='_') ; Else if(s[i]>='a'&& s[i]<='Z')            {                 if(s[i-1]=='_') T[k+ +] = s[i]- +; Elset[k++] =S[i]; }} printf ("%s\n", T); }    return 0;}
View Code

C + + and Java (analog)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.