题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
#include <ctype.h>
#include <stdio.h>
int main()
{
int a,b,c,e,f;
char str1[100];
char str2[100]={"\0"};
gets(str1);
a=strlen(str1);
e=0;
for(c=0;c<a;c++)
{
if(isdigit(str1[c]))
str2[e++]=str1[c];
else if(islower(str1[c]))
{
if(str1[c]=='a'||str1[c]=='b'||str1[c]=='c')
str2[e++]='2';
else if(str1[c]=='d'||str1[c]=='e'||str1[c]=='f')
str2[e++]='3';
else if(str1[c]=='g'||str1[c]=='h'||str1[c]=='i')
str2[e++]='4';
else if(str1[c]=='j'||str1[c]=='k'||str1[c]=='l')
str2[e++]='5';
else if(str1[c]=='m'||str1[c]=='n'||str1[c]=='o')
str2[e++]='6';
else if(str1[c]=='p'||str1[c]=='q'||str1[c]=='r'||str1[c]=='s')
str2[e++]='7';
else if(str1[c]=='t'||str1[c]=='u'||str1[c]=='v')
str2[e++]='8';
else if(str1[c]=='w'||str1[c]=='x'||str1[c]=='y'||str1[c]=='z')
str2[e++]='9';
}
else if(isupper(str1[c])&&str1[c]!='Z')
{
str2[e++]=str1[c]+1+32;
}
else if(str1[c]=='Z')
str2[e++]='a';
}
e--;
puts(str2);
}

CVTE公司福利 691人发布
查看20道真题和解析