-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGCPCIIF.cpp
More file actions
57 lines (57 loc) · 729 Bytes
/
GCPCIIF.cpp
File metadata and controls
57 lines (57 loc) · 729 Bytes
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
#include <iostream>
#include<algorithm>
using namespace std;
#include<cstdio>
int main() {
int t;
scanf("%d\n",&t);
char s[1001];
while(t--)
{
int a[26]={0},i;
gets(s);
//printf("%s\n",s);
for(i=0;s[i];i++)
{
if(s[i]!=' ')
a[s[i]-65]++;
}
int c=1;
int m=0;
for(i=1;i<26;i++)
{
//printf("%d ",a[i]);
if(a[i]>a[m])
{
m=i;
c=1;
}
else if(a[i]==a[m])
c++;
}
//printf("\n%d ",m);
if(c>1)
{
printf("NOT POSSIBLE\n");
continue;
}
int d;
if(m>=4)
d=m-4;
else
d=26-4+m;
printf("%d ",d);
for(i=0;s[i];i++)
{
if(s[i]!=' ')
{
if(s[i]-d<65)
s[i] = s[i]-d + 26;
else
s[i]=s[i]-d;
}
}
printf("%s\n",s);
}
return 0;
}