描述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. Hadoop概念学习系列之分布式数据集的容错性(二十七)

    一般来说,分布式数据集的容错性有两种方式: 1.数据检查点 2.记录数据的更新 我们面向的是大规模数据分析,数据检查点操作成本很高:需要通过数据中心的网络连接在机器之间复制庞大的数据集,而网络带宽往往 ...

  2. CSS 居中大全

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

  3. vim之grep

    [vim之grep] :vimgrep 用于多文件搜索,如 1):vim[grep] start_stage *   在当前目录下(不包括子目录)搜索 2)  :vim[grep] start_sta ...

  4. LeetCode7:Reverse Integer

    Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 click to ...

  5. Vusual C++连接Mysql和从MySql中取出数据的API介绍

    .1 mysql_real_connect() 2.1.1 函数原型: MYSQL *mysql_real_connect(MYSQL *mysql, const char *host, const ...

  6. 1001.A+B Format (20)(思路,bug发现及其修改,提交记录)

    https://github.com/031502316a/object-oriented/tree/master/1001 ---恢复内容开始--- 1.解题思路 一开始见到题目时,感觉难的就是输出 ...

  7. Codeforces 588E. A Simple Task (线段树+计数排序思想)

    题目链接:http://codeforces.com/contest/558/problem/E 题意:有一串字符串,有两个操作:1操作是将l到r的字符串升序排序,0操作是降序排序. 题解:建立26棵 ...

  8. jgroups 常见概念

    组播(Multicast)传输:在发送者和每一接收者之间实现点对多点网络连接. 单播(Unicast)传输:在发送者和每一接收者之间实现点对点网络连接. 广播(Broadcast)传输:是指在IP子网 ...

  9. WCF WEB API配置

    Web.config配置 <system.serviceModel> <services> <service name="WCFServiceWebRole2. ...

  10. Oracle复制表结构和表数据

    一, 复制表结构及数据 create table z_xudebiao_test as select * from v_topic v where v.adddate > to_date('20 ...