Strings in C/C++ examples
1.Username
There is a site on which users have to make orders to use it. The site accepts only user names that are longer than 6 characters and shorter than 14. Write a program that checks the username.
Input
The entry is one word that represents a username.
Output
In case the username has more than 6 and less than 14 letters, print:
Created the name for the user [User name].
In the case that the user name has 6 or less characteristic, print:
No user name created. Thank you X letters.
In case the user name has 14 or more letters, print:
No user name created. You have X letters of whiskey.
The entry is one word that represents a username.
Output
In case the username has more than 6 and less than 14 letters, print:
Created the name for the user [User name].
In the case that the user name has 6 or less characteristic, print:
No user name created. Thank you X letters.
In case the user name has 14 or more letters, print:
No user name created. You have X letters of whiskey.
2.Palindrom string
Is it a string palindrome? Palindrome is a string that is read alike from left and right, ignoring spaces and punctuation marks
Input
In the first and only row of the input, there is a string S.
Output
The output should consist of one word: "yes" if the string is a palindrome, "no" if it is not.
Limitations
The length of the string S is between 1 and 1 000 000 characters.
Characters that can appear in the string:
- upper and lower case letters of the English alphabet
- punctuation marks: ! ; : '"? ()
- empty space
In the first and only row of the input, there is a string S.
Output
The output should consist of one word: "yes" if the string is a palindrome, "no" if it is not.
Limitations
The length of the string S is between 1 and 1 000 000 characters.
Characters that can appear in the string:
- upper and lower case letters of the English alphabet
- punctuation marks: ! ; : '"? ()
- empty space
3.Anagrams
Write a program that checks whether the two data string is anagrams to each other.
Input
Two strings, each in a separate line.
Output
"yes" in case the strings are anagrams, "no" otherwise.
Example
Input
ortoped
torpedo
Output
Yes
Two strings, each in a separate line.
Output
"yes" in case the strings are anagrams, "no" otherwise.
Example
Input
ortoped
torpedo
Output
Yes
4. Lexicographic minimum
Write a program that determines which of the several words should be listed first in the dictionary if there is no difference between uppercase and lowercase letters (for that word we say it is lexicographically ahead of other words, that is, lexical is the smallest among all words).
Input
From the standard input, a line of text containing multiple words is separated with exactly one space (there is at least one word in the line, and there is no space behind the last word).
Output
On the standard output, print the word from the loaded line, which is lexical in front of other words.
From the standard input, a line of text containing multiple words is separated with exactly one space (there is at least one word in the line, and there is no space behind the last word).
Output
On the standard output, print the word from the loaded line, which is lexical in front of other words.
5. The value of the expression
Write a program that calculates the value of a simple arithmetic expression (eg 123 * 456).
Input
From a standard input, a line of text is loaded that contains a simple arithmetic expression obtained by applying the addition, subtraction or multiplication operations to two natural numbers. The text loaded does not contain spaces. Note: For exercises, load the whole string containing the expression, and then break it into pieces.
Output
On the standard output print the expression value (it is certainly between -10 ^ 9 and 10 ^ 9).
Example
Input
32 + 73
Output
105
From a standard input, a line of text is loaded that contains a simple arithmetic expression obtained by applying the addition, subtraction or multiplication operations to two natural numbers. The text loaded does not contain spaces. Note: For exercises, load the whole string containing the expression, and then break it into pieces.
Output
On the standard output print the expression value (it is certainly between -10 ^ 9 and 10 ^ 9).
Example
Input
32 + 73
Output
105
5. Caesar's code
The given word is composed of the small letters of the Roman alphabet (which is the same as English). You need to encrypt or decrypt the message. Caesar's code is a type of substitution code in which every letter of encrypted text is changed by the letter of the alphabet obtained by moving the initial letters for a certain number of places, cyclically in alphabetical order. For example, if moving for two places, the letter abi was encrypted with the letter d, b letter e, etc., while the letter w would be encoded by letter z, letter x with letter a, letter y, letter b, and letter with letter c. For example, the parrot word would be encrypted with sdsdjdm.
Input
In the first line of the standard input there is a word not longer than 100 letters, in the second line there is an integer N, which represents a shift (1≤N <26), and in the third integer S, which represents the direction of encryption. If S = 1S = 1 it is necessary to encrypt it, and if S = 2 it is necessary to decrypt the word.
Output
In the first line of the standard output, display the word that is obtained after encryption, i.e. decipher the word.
Example1
Input
abcdefghijklmnopqrstuvwxyz
3
1
Output
defghijklmnopqrstuvwxyzabc
Example 2
Input
twornuvkpemkp
2
2
Output
rumplstinckin
In the first line of the standard input there is a word not longer than 100 letters, in the second line there is an integer N, which represents a shift (1≤N <26), and in the third integer S, which represents the direction of encryption. If S = 1S = 1 it is necessary to encrypt it, and if S = 2 it is necessary to decrypt the word.
Output
In the first line of the standard output, display the word that is obtained after encryption, i.e. decipher the word.
Example1
Input
abcdefghijklmnopqrstuvwxyz
3
1
Output
defghijklmnopqrstuvwxyzabc
Example 2
Input
twornuvkpemkp
2
2
Output
rumplstinckin
6. Arabic in Roman
Write a program that translates an Arabic number into Roman.
Input
The natural number n is entered from the input (1≤n≤2000)
Output
The standard output prints the Roman record of n.
Example
Input
1978
Output
MCMLXXVIII
The natural number n is entered from the input (1≤n≤2000)
Output
The standard output prints the Roman record of n.
Example
Input
1978
Output
MCMLXXVIII