描述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
样例输入
  1. 6
  2. R 1
  3. P 2
  4. G 3
  5. r 1
  6. p 2
  7. g 3
样例输出
  1. 19
  2. 18
  3. 10
  4. -17
  5. -14
  6. -4
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. Scanner scanner=new Scanner(System.in);
  6. int T;
  7. char s[]=new char[1];
  8. int result;
  9. int number;
  10.  
  11. T=scanner.nextInt();
  12. while(true){
  13. if(T==0)
  14. break;
  15. T--;
  16.  
  17. s=scanner.next().toCharArray();
  18. number=scanner.nextInt();
  19.  
  20. if(s[0]>='a' && s[0]<='z'){
  21. result=-(s[0]-'a'+1)+number;
  22. }
  23. else
  24. result=(s[0]-'A'+1)+number;
  25.  
  26. System.out.println(result);
  27. }
  28. }
  29. }
  1.  

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. Azure linux centos 默认登陆账号是什么?

    什么?刚创建的linux虚拟机账号忘记了? 不要急,往下看!! Azure为我们考虑好了,默认创建centos 系统时,默认账号是azureuser,这个账号是非root权限的. 很多人在创建的时候容 ...

  2. HDOJ_1010 Tempter of the Bone

    http://acm.hdu.edu.cn/showproblem.php?pid=1010 奇偶剪枝:可以把map看成这样: 0 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 0 1 ...

  3. 完成端口iocp——在螺丝壳里做道场

    WINDOWS 2000以后的操作系统才支持IOCP.WINSOCK2.0才支持IOCP. 首先要有一个WINSOCK2.PAS的WINSOCK2.0接口调用声明单元. WINSOCK的版本号: WI ...

  4. MVC6与Asp.net5

    http://www.cnblogs.com/n-pei/p/4263148.html https://blogs.msdn.microsoft.com/scottgu/2015/04/30/asp- ...

  5. ags js下载地址

    https://developers.arcgis.com/en/downloads/ 备用

  6. TCP客户机-服务器

    1 僵尸进程 2 信号处理 信号: 1 由一进程发往另一进程 2 由内核发往某进程   僵尸状态: 父进程取回子进程的相关信息,进程的ID,终止状态,子进程的资源利用信息   编程时: 1 当派生子进 ...

  7. 12.组合(Composition)

    组合也是关联关系的一种特例,它体现的是一种contains-a的关系,这种关系比聚合更强,也称为强聚合:它同样体现整体与部分间的关系,但此时整体与部分是不可分的,它们具有统一的生存期,整体的生命周期结 ...

  8. 如何判断js中的数据类型(转)

    如何判断js中的数据类型:typeof.instanceof. constructor. prototype方法比较 如何判断js中的类型呢,先举几个例子: var a = "iamstri ...

  9. IAR EWARM Argument variables $PROJ_DIR$ $TOOLKIT_DIR$

    在IAR中的help中输入argument variables时会找到这样的一个列表: Argument variables On many of the pages in the Options d ...

  10. Pre-compile (pre-JIT) your assembly on the fly, or trigger JIT compilation ahead-of-time (转)

    Introduction All .NET developers know that one of the best features of the CLR is JIT-compilation: J ...