题目链接
题解:这道题很简单,但错了很多次,原因就是‘\’的输出需要再printf/cout里面写两次。
下面是WA代码:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
string s;getline(cin,s);for(int i=0;i<s.size();i++){
if(s[i]=='a'||s[i]=='A') printf("@");else if(s[i]=='b'||s[i]=='B') printf("8");else if(s[i]=='c'||s[i]=='C') printf("(");else if(s[i]=='d'||s[i]=='D') printf("|)");else if(s[i]=='e'||s[i]=='E') printf("3");else if(s[i]=='f'||s[i]=='F') printf("#");else if(s[i]=='g'||s[i]=='G') printf("6");else if(s[i]=='h'||s[i]=='H') printf("[-]");else if(s[i]=='i'||s[i]=='I') printf("|");else if(s[i]=='j'||s[i]=='J') printf("_|");else if(s[i]=='k'||s[i]=='K') printf("|<");else if(s[i]=='l'||s[i]=='L') printf("1");else if(s[i]=='m'||s[i]=='M') printf("[]\/[]");else if(s[i]=='n'||s[i]=='N') printf("[]\[]");else if(s[i]=='o'||s[i]=='O') printf("0");else if(s[i]=='p'||s[i]=='P') printf("|D");else if(s[i]=='q'||s[i]=='Q') printf("(,)");else if(s[i]=='r'||s[i]=='R') printf("|Z");else if(s[i]=='s'||s[i]=='S') printf("$");else if(s[i]=='t'||s[i]=='T') printf("']['");else if(s[i]=='u'||s[i]=='U') printf("|_|");else if(s[i]=='v'||s[i]=='V') printf("\/");else if(s[i]=='w'||s[i]=='W') printf("\/\/");else if(s[i]=='x'||s[i]=='X') printf("}{");else if(s[i]=='y'||s[i]=='Y') printf("`/");else if(s[i]=='z'||s[i]=='Z') printf("2");else printf("%c",s[i]);}return 0;
}
下面是AC代码:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
string s;getline(cin,s);for(int i=0;i<s.size();i++){
if(s[i]=='a'||s[i]=='A') printf("@");else if(s[i]=='b'||s[i]=='B') printf("8");else if(s[i]=='c'||s[i]=='C') printf("(");else if(s[i]=='d'||s[i]=='D') printf("|)");else if(s[i]=='e'||s[i]=='E') printf("3");else if(s[i]=='f'||s[i]=='F') printf("#");else if(s[i]=='g'||s[i]=='G') printf("6");else if(s[i]=='h'||s[i]=='H') printf("[-]");else if(s[i]=='i'||s[i]=='I') printf("|");else if(s[i]=='j'||s[i]=='J') printf("_|");else if(s[i]=='k'||s[i]=='K') printf("|<");else if(s[i]=='l'||s[i]=='L') printf("1");else if(s[i]=='m'||s[i]=='M') printf("[]\\/[]");else if(s[i]=='n'||s[i]=='N') printf("[]\\[]");else if(s[i]=='o'||s[i]=='O') printf("0");else if(s[i]=='p'||s[i]=='P') printf("|D");else if(s[i]=='q'||s[i]=='Q') printf("(,)");else if(s[i]=='r'||s[i]=='R') printf("|Z");else if(s[i]=='s'||s[i]=='S') printf("$");else if(s[i]=='t'||s[i]=='T') printf("']['");else if(s[i]=='u'||s[i]=='U') printf("|_|");else if(s[i]=='v'||s[i]=='V') printf("\\/");else if(s[i]=='w'||s[i]=='W') printf("\\/\\/");else if(s[i]=='x'||s[i]=='X') printf("}{");else if(s[i]=='y'||s[i]=='Y') printf("`/");else if(s[i]=='z'||s[i]=='Z') printf("2");else printf("%c",s[i]);}return 0;
}
类似的符号还用%等