Home > Back-end >  The program is the fifth edition Tan Haoqiang c programming book, chapter 6 number 12. Will A to Z,
The program is the fifth edition Tan Haoqiang c programming book, chapter 6 number 12. Will A to Z,

Time:09-26

CodePudding user response:

This is I compiled code
#include
#include
Int main ()
{
Char a, [10].
int i=0;
int x;
Printf (" both please input your password: ");
for(i=0; i<10; I++)
{
The scanf (" % c ", a [I]);
}
For (I=0; i<10; I++)
{
If (a [I] & gt;=65 & amp; & A [I] <=90 | | a [I] & gt;=97 & amp; & A [I] <=122);
{
X=a, [I] - 64.
A [I]=26 - x + 65;
}

}
Printf (" \ nThe real password: % s \ n ", a);

Return 0;
}

CodePudding user response:

The scanf (" % c ", & amp; A [I]);

The scanf (" % s ", a);

CodePudding user response:

 # include 
#include

Int main ()
{
Char a, [10].
int i=0;
int x;

Printf (" both please input your password: ");
for(i=0; i<10; I++)
{
//the scanf (" % c ", a [I]);
The scanf (" % c ", & amp; A [I]);
}
For (I=0; i<10; I++)
{
//if ((a [I] & gt;=65 & amp; & A [I] <=90) | | (a [I] & gt;=97 & amp; & A [I] <=122));
If ((a [I] & gt;=65 & amp; & A [I] <=90))
{
A [I]='a' + a [I] - 'a' + 25) % 26;
//x=a, [I] - 64.
//a [I]=26 - x + 65;
} else if (a [I] & gt;=97 & amp; & A [I] <{
=122)A [I]='a' + a [I] - 'a' + 25) % 26;
}

}
Printf (" \ nThe real password: % s \ n ", a);

Return 0;
}

For your reference ~

CodePudding user response:

If conditional statements from A& there; & B | | C& & D into (A& & B) | | (C& & D) to have a look, can guarantee the judge order is right, as if & amp; & Higher priority than | | - I can turn on c prime plus has said

CodePudding user response:

Thank you very much for your help, I try your method, use

CodePudding user response:

On the third floor is correct, first the scanf is the need to address, you can have a good look at the prototype, and second, the judgment of the upper and lower case can't together, is not the same, the starting point of the two values and incoherent, directly according to the capital operation is likely to change to the alphabetic characters