Home > Back-end >  Zhengzhou university of light industry the 11th blue cup competition
Zhengzhou university of light industry the 11th blue cup competition

Time:06-03

Blue bridge internal audition antithesis
Input a word, please output the word first appeared in vowels,
Including vowels a, e, I, o, u, a total of five,
Input format
Input line contains a word, containing only lowercase English letters in the word,
The output format
Output a line contains a letter, as the words of the first occurrence of elements of letters, if the word does not exist in the yuan
Letters, output n,
The sample input hello
Sample output
E
The sample input
Fly
Sample output
N
#include
#include
Int main ()
{
Char STR [100].
The scanf (" % s ", STR);
Int a=strlen (STR);
Int I, b=0;
for(i=0; i{
If (STR [I]=='a' | | STR [I]=='e' | | STR [I]=='I' | | STR [I]=='o' | | STR [I]=='u')
{
Printf (" % c \ n ", STR [I]);
B++;
break;
}

}
If (b==0)
{
Printf (" n \ n ");
}
return 0;
}
Note: this topic understanding the input string array and judging its length so that the number of control loop, and then appeared to jump out of the loop when the first vowel in break statement, but early know at the end of the if statement,


2. Given a word, the word please use Caesar password will be encrypted,
Caesar cipher is a kind of replacement encryption technology, all the letters of the word on the alphabet backwards offset 3
After being replaced with ciphertext, namely a to d, b to e... W to z, x into a, b, y z
C,
For example, will become odqtldr lanqiao,
Input format
Input line contains a word, containing only lowercase English letters in the word,
The output format
Output a line, said the encrypted ciphertext,
The sample input
Lanqiao
Sample output
Odqtldr

#include
#include
Int main ()
{
Char STR [100].
The scanf (" % s ", STR);
Int I, a;
A=strlen (STR);
for(i=0; i{
If (STR [I] & gt;='a' & amp; & STR [I] <)
='w'{
STR=STR [I] [I] + 3;
}
Else if (STR [I]=='x')
{
STR [I]='a';
}
Else if (STR [I]=='y')
{
STR=[I] 'b';
}
The else
{
STR [I]='c';
}
}
Printf (" % s ", STR);
return 0;
}
Note: subject train of thought, understand the input of the string, using an array of strings convert letters one by one, pay attention to a few special cases such as x, y, z transformation

CodePudding user response:

 # include & lt; Stdio. H> 
#include
#include


Int encrypt (int ch, int n)
{
If (islower (ch))
Return the 'a' + (ch - 'a' + n) % 26;
If (isupper (ch))
Return the 'A' + (ch - 'A' + n) % 26;

return ch;
}


Int main ()
{
Char STR [100].
The scanf (" % s ", STR);
Int I, a;
A=strlen (STR);
for(i=0; i{
STR [I]=encrypt (STR [I], 3);
}


For your reference ~

CodePudding user response:

I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related