An easy problem
2014-10-29 00:48
232 查看
[align=left]Problem Description[/align]
we define f(A) = 1, f(a) = -1, f(B) = 2, f(b) = -2, ... f(Z) = 26, f(z) = -26;
Give you a letter x and a number y , you should output the result of y+f(x).
[align=left]Input[/align]
On the first line, contains a number T.then T lines follow, each line is a case.each case contains a letter and a number.
[align=left]Output[/align]
for each case, you should the result of y+f(x) on a line.
[align=left]Sample Input[/align]
6
R 1
P 2
G 3
r 1
p 2
g 3
[align=left]Sample Output[/align]
19
18
10
-17
-14
-4
we define f(A) = 1, f(a) = -1, f(B) = 2, f(b) = -2, ... f(Z) = 26, f(z) = -26;
Give you a letter x and a number y , you should output the result of y+f(x).
[align=left]Input[/align]
On the first line, contains a number T.then T lines follow, each line is a case.each case contains a letter and a number.
[align=left]Output[/align]
for each case, you should the result of y+f(x) on a line.
[align=left]Sample Input[/align]
6
R 1
P 2
G 3
r 1
p 2
g 3
[align=left]Sample Output[/align]
19
18
10
-17
-14
-4
#include <stdio.h> #include <ctype.h> int main(){ int T; char c; int number; int result; scanf("%d",&T); while(T--){ getchar(); scanf("%c%d",&c,&number); if(islower(c)!=0){ result=c-'a'+1; result=-result; result+=number; } else{ result=c-'A'+1; result+=number; } printf("%d\n",result); } return 0; }
相关文章推荐
- 2055——An easy problem
- POJ 2826 An Easy Problem? 判断线段相交
- POJ 2826 An Easy Problem?!
- HDU 5475 An easy problem(网络赛水题)
- UESTC - 1597 An easy problem C (线段树)
- HDU 2055 An easy problem
- poj 2453 An Easy Problem
- An Easy Problem
- HDU 2055 An easy problem
- 【线段树】单点更新 hdu 5475 An easy problem
- 1455:An Easy Problem(4.6算法之贪心)
- An Easy Problem!
- POJ 2826 An Easy Problem?!
- PKU 2453 An Easy Problem
- hdoj 2055 An easy problem
- O - An easy problem
- hdoj 2601 An easy problem(数学)
- HDU-5572-An Easy Physics Problem
- hdu2123 An easy problem (水。)
- HDU 2123 An easy problem