-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP1071.cpp
67 lines (58 loc) · 1.17 KB
/
P1071.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <stdio.h>
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char map[26];
int flag[26] = {0};//ÃÜÎı»Ê¹ÓÃ
int ff[26] = {0};//Ã÷Îı»Ê¹ÓÃ
char a[4][101];
int num = 0;
for (int i = 1; i <= 3;i++)
{
scanf("%s", a[i]);
}
int length1 = strlen(a[1]);
int length2 = strlen(a[2]);
if(length1<26)
{
printf("Failed");
return 0;
}
int locate = 0;
int locate1 = 0;
for (int i = 0; i < length1;i++)
{
locate = a[1][i] - 'A';
locate1 = a[2][i] - 'A';
if(flag[locate]==0&&ff[locate1]==0)
{
map[locate] = a[2][i];
flag[locate] = 1;
ff[locate1] = 1;
num++;
}
else
{
flag[locate] = 1;
if(map[locate]!=a[2][i])
{
printf("Failed");
return 0;
}
}
}
if(num!=26)
{
printf("Failed");
return 0;
}
for (int i = 0; i < strlen(a[3]);i++)
{
locate = a[3][i] - 'A';
a[0][i] = map[locate];
printf("%c", a[0][i]);
}
return 0;
}