-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathABCD2.cpp
69 lines (44 loc) · 1.21 KB
/
ABCD2.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
68
69
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
int n;
scanf("%d",&n);
string s1,s2="";
//char a[2][2*N];
cin>>s1;
char t='E';
int count[4]={0};
int len=s1.length();
for(int i=0;i<len;i=i+2)
{
count[(int)s1[i]-65]++;
count[(int)s1[i+1]-65]++;
int j=0;
char x[2];
for(int k=0;k<4;k++)
{
if(count[k]==0)
{
x[j]=k+65;
j++;
}
}
for(int i=0;i<4;i++)
count[i]=0;
if(t==x[0])
{
s2=s2+x[1]+x[0];
t=x[0];
}
else
{
s2=s2+x[0]+x[1];
t=x[1];
}
}
cout<<s2<<endl;
system ("pause");
return 0;
}