描述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. CSS 居中大全

    <center> text-align:center 在父容器里水平居中 inline 文字,或 inline 元素 vertical-align:middle 垂直居中 inline 文 ...

  2. keycode按键对照表

    功能场景,鼠标在某区域内,比如多个条件的搜索框内,按下enter键让其具有,点击 [确定/搜索]按钮的功能.在编辑的区域内,点击enter键,让其有 [保存]按钮的功能.则可这样:$("#s ...

  3. DataTable添加行和列

    tablenullobjectdatasetc#c 手动插入一行数据 DataSet ds = tTalent.GetAllInfo();         DataRow dr = ds.Tables ...

  4. COM组件(ActiveX)控件注册失败

    这主要是由于旧版本的falsh player的原因,卸载干净并清理注册表,再次安装flash player即可. 具体方法: 1 在控制面板 卸载程序里面 卸载flash player 2 C:\WI ...

  5. Flex利用titleIcon属性给Panel容器标题部添加一个ICON图标

    Flex利用titleIcon属性,给Panel容器标题部添加一个ICON图标. 让我们先来看一下Demo(可以右键View Source或点击这里察看源代码): 下面是完整代码(或点击这里察看): ...

  6. NAT类型与穿透 及 STUN TURN 协议

    STUN : Simple Traversal of User Datagram Protocol [UDP] Through Network Address Translators [NATs] S ...

  7. Windows性能计数器2

    判断瓶颈 Ø 判断应用程序的问题 如果系统由于应用程序代码效率低下或者系统结构设计有缺陷而导致大量的上下文切换(context switches/sec显示的上下文切换次数太高)那么就会占用大量的系统 ...

  8. ARM&Linux 下驱动开发第二节

    驱动文件:qudong.c,make生成qudong.ko文件,烧录到ARM板上 #include<linux/init.h> #include<linux/module.h> ...

  9. MySQL中进行树状所有子节点的查询

    在Oracle 中我们知道有一个 Hierarchical Queries 通过CONNECT BY 我们可以方便的查了所有当前节点下的所有子节点.但很遗憾,在MySQL的目前版本中还没有对应的功能. ...

  10. Cocos2dx Widget button透明区域过滤

    小伟哥 遇到一个命题: button透明区域过滤.当点击一个建筑button.花的时候不得不想一些方法把点击透明区域过滤掉. 让点击也没有效果滴啦. 開始搜索了半天才有所思路. 在网络上非常多贴代码的 ...