-
Notifications
You must be signed in to change notification settings - Fork 0
/
warmup3.cpp
52 lines (48 loc) · 921 Bytes
/
warmup3.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
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int make_palindromo(string temp)
{
int i = 0;
int j = temp.length() - 1;
int cont = 0;
while(i < j)
{
if(temp[i] < temp[j])
{
cont+= temp[j] - temp[i];
}
else if(temp[j] < temp[i])
{
cont+= temp[i] - temp[j];
}
i++;
j--;
}
return cont;
}
int main()
{
int T = 0;
string temp = "";
cin >> T;
int result[T];
for(int i = 0 ; i < T; i ++)
{
cin>> temp;
result[i] = make_palindromo(temp);
}
for(int i = 0 ; i < T; i++)
{
if(i == T - 1)
cout<<result[i];
else
cout<< result[i]<<endl;
}
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
return 0;
}