我一开始竟然用getchar(),挂了!
理解好题! 要考虑到plaintext 里可能出现空格,所以不能用cin读!
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main()
{
char ch[70];
char str1[100],str2[100];
int i,j,len1;
cin.getline(str1,100);
len1 = strlen(str1);
cin.getline(str2,100);
cout<<str2<<"\n"<<str1<<endl;
while(cin.getline(ch,70))
{
ch[strlen(ch)] = '\0';
i = 0;
while(ch[i] != '\0')
{
for(j = 0;j < len1;j ++)
{
if(ch[i] == str1[j])
{cout<<str2[j];break;}
}
if(j == len1)cout<<ch[i];
i++;
}
cout<<endl;
}
return 0;
}