【杭电-oj】-2055-An easy problem
2016-06-27 17:23
381 查看
An easy problem
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 20399 Accepted Submission(s): 13565
Problem Description
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).
Input
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.
Output
for each case, you should the result of y+f(x) on a line.
Sample Input
6
R 1
P 2
G 3
r 1
p 2
g 3
Sample Output
19
18
10
-17
-14
-4
Author
8600
开始输入一个数字,后来输入字符是注意用getchar()吸收换行符!!!多次输出也需要。
#include<cstdio>
#include<cstring>
int main()
{
int n;
scanf("%d",&n);
getchar();
while(n--)
{
char a;
int y;
scanf("%c %d",&a,&y);
if(a>='a'&&a<='z')
printf("%d\n",y-(a-'a'+1));
else
printf("%d\n",y+(a-'A'+1));
getchar();
}
return 0;
}
相关文章推荐
- 决策树、逻辑回归、线性回归使用时注意事项以及模型过拟合策略
- 手把手教你使用Git
- Spring MVC File Upload Example Tutorial – Single and Multiple Files
- 服务端入门《五》(gdb 调试)
- 添加一些语言后,切换到该语言手机自动重启,添加ICU资源
- CI框架简单使用方法
- Mysql游标使用
- 【Matplotlib】详解图像各个部分
- Longest Substring Without Repeating Characters Leetcode Python Java
- easyui window弹窗获取x事件
- float属性与clear属性综合讲解与实例
- Appnium+python实现手势密码为什么总是报错
- C#键盘按键对应Keys类大全
- LeetCode—368. Largest Divisible Subset
- Android 中启动一个activity,怎么写才好
- 检查网络状态
- android 中的inclue标签中出现的空指针问题
- sed,grep,awk以及一些正则
- [从头读历史] 第271节 诗经 郑风
- linux/unix下svn自动更新post-commit hook failed (exit code 255)