描述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).

 
输入
On the first line, contains a number T(0<T<=10000).then T lines follow, each line is a case.each case contains a letter x and a number y(0<=y<1000).
输出
for each case, you should the result of y+f(x) on a line
样例输入
6
R 1
P 2
G 3
r 1
p 2
g 3
样例输出
19
18
10
-17
-14
-4
 import java.util.Scanner;

 public class Main {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
int T;
char s[]=new char[1];
int result;
int number; T=scanner.nextInt();
while(true){
if(T==0)
break;
T--; s=scanner.next().toCharArray();
number=scanner.nextInt(); if(s[0]>='a' && s[0]<='z'){
result=-(s[0]-'a'+1)+number;
}
else
result=(s[0]-'A'+1)+number; System.out.println(result);
}
}
}
 

a letter and a number的更多相关文章

  1. nyoj 217-a letter and a number (char)

    217-a letter and a number 内存限制:64MB 时间限制:3000ms 特判: No 通过数:4 提交数:5 难度:1 题目描述: we define f(A) = 1, f( ...

  2. Topcoder SRM 627 div1 HappyLettersDiv1 : 字符串

    Problem Statement      The Happy Letter game is played as follows: At the beginning, several players ...

  3. shell流程控制&函数

    条件 if-then-elif-then-fi if的条件部分经常使用test EXPRESSION或[ EXPRESSION ]实现,test的用法可以参见test if 条件1 #if 条件1;t ...

  4. Differences between volume, partition and drive

    A drive is a physical block disk. For example: /dev/sda. A partition A drive can be divided into som ...

  5. Typographical Concepts

    Glyph(字形) A glyph is an element of writing: an individual mark on a written medium that contributes ...

  6. 转载:fstream和ifstream详细用法

    文件 I/O 在C++中比烤蛋糕简单多了.在这篇文章里,我会详细解释ASCII和二进制文件的输入输出的每个细节,值得注意的是,所有这些都是用C++完成的. 一.ASCII 输出 为了使用下面的方法, ...

  7. C++文件读写总结

    在C++中如何实现文件的读写? 作者: infobillows 发表日期: 2007-04-03 21:33 点击数: 465 一.ASCII 输出 为了使用下面的方法, 你必须包含头文件<fs ...

  8. HDOJ 2055 An easy problem

    Problem Description we define f(A) = 1, f(a) = -1, f(B) = 2, f(b) = -2, - f(Z) = 26, f(z) = -26; Giv ...

  9. HDU_2055——刷题不要使用fflush()

    Problem Description we define f(A) = 1, f(a) = -1, f(B) = 2, f(b) = -2, ... f(Z) = 26, f(z) = -26; G ...

随机推荐

  1. Matlab 图像画在坐标轴下

    >> x=linspace(,*pi,); >> y=sin(x); >> figure;plot(x,y,'r-') >> set(gca,'xaxi ...

  2. KMP算法——Javascript实现

    腾讯和阿里的笔试刚过去了,里面有很多题都很值得玩味的.之前Blog积累的很多东西,还要平时看的书,都有很大的帮助.这个深有体会啊! 例如,腾讯有一道算法题是吃香蕉(好邪恶的赶脚..),一次吃一根或者两 ...

  3. java 对excel操作 读取、写入、修改数据;导出数据库数据到excel

    ============前提加入jar包jxl.jar========================= // 从数据库导出数据到excel public List<Xskh> outPu ...

  4. [转][IIS]发布网站,提示用户 'IIS APPPOOL\***' 登录失败。

    链接:http://www.cnblogs.com/tianguook/p/3881075.html 用户 'IIS APPPOOL\DefaultAppPool' 登录失败. 我在windows8中 ...

  5. c\c++ 字符串处理大集合[转]

    rember this strncpy(a,b,); a[]='\0'; ]; memset(a,'#',sizeof(a)); a[]='\0'; 刚开始学C/C++时,一直对字符串处理函数一知半解 ...

  6. 【AS3 Coder】任务七:初涉PureMVC——天气预报功能实现

    转自:http://www.iamsevent.com/post/36.html AS3 Coder]任务七:初涉PureMVC——天气预报功能实现 使用框架:AS3任务描述:了解PureMVC框架使 ...

  7. position:sticky用法

    用户的屏幕越来越大,而页面太宽的话会不宜阅读,所以绝大部分网站的主体宽度和之前相比没有太大的变化,于是浏览器中就有越来越多的空白区域,所以你可能注意到很多网站开始在滚动的时候让一部分内容保持可见,比如 ...

  8. winrar激活

    (从已经死了一次又一次终于挂掉的百度空间人工抢救出来的,发表日期2014-02-11) 新建记事本文件(txt文件),然后将文件另存为以 rarreg.key 为文件名的文件(当然由于设置的不同,可能 ...

  9. baseDao 使用spring3+hibernate3方式

    package cn.zk.pic.service.dao; import java.io.Serializable; import java.util.List; import java.util. ...

  10. Hadoop on Mac with IntelliJ IDEA - 7 解决failed to report status for 600 seconds. Killing!问题

    本文讲述作业在Hadoop 1.2.1完成map后ruduce阶段遇到failed to report status for 600 seconds. Killing!问题的解决过程. 环境:Mac ...