以你的代码为基础看,其他字符作为最后的else语句处理最好,这样就不用写那么长的判断语句,而且也更好的保证代码准确性
#include <stdio.h>
#include <math.h>
int main()
{
char A,B,C,D;
scanf("%c",&A);
if(A>=48 && A<=57)
{
B = A + 2;
printf("%c",B);
}
else if(A>=97 && A<=122)
{
C = A + 4;
printf("%c",C);
}
else if(A>=65 && A<=90)
{
D = A + 3;
printf("%c",D);
}
else
{
printf("%c",A);
}
return 0;
}
你试试这个
#include <stdio.h>
#include <math.h>
int main(void) {
char c;
scanf("%c", c);
if(c >= 97 && c <= 122){
c += 2;
}
else if(c >= 65 && c <= 90){
c += 3;
}
else if(c >= 48 && c <= 57){
c += 4;
}
printf("%c", c);
return 0;
}
有用望采纳