HDU_2055解题报告(JAVA)
来源:互联网 发布:淘宝官方下载 编辑:程序博客网 时间:2024/06/14 09:10
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;
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
import java.util.*;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for(int i=0;i<n;i++){ String a = sc.next(); String b = sc.next(); char a1 = a.charAt(0); int b1 = Integer.valueOf(b); if(65<=a1&&a1<=90){ System.out.println((b1+a1-64)); } if(97<=a1&&a1<=122){ System.out.println((b1-a1+96)); } } }}
在Java中,next()方法是不接收空格的,在接收到有效数据前,所有的空格或者tab键等输入被忽略,若有有效数据,则遇到这些键退出。
nextLine()可以接收空格或者tab键,其输入应该以enter键结束。
0 0
- HDU_2055解题报告(JAVA)
- POJ1118 解题报告JAVA
- POJ1207解题报告 Java
- Java与C++ 解题报告
- POJ 1001 Exponentiation C++解题报告 JAVA解题报告
- POJ 1009 Edge Detection 解题报告 JAVA
- ZOJ 3714 Java Beans 解题报告
- 杭电ACM1016解题报告(Java)
- POJ 1451 T9 [解题报告] Java
- POJ 1001 Exponentiation [解题报告] Java
- POJ 1002 487-3279 [解题报告] Java
- POJ 1003 Hangover [解题报告] Java
- POJ 1004 Financial Management [解题报告] Java
- POJ 1006 Biorhythms [解题报告] Java
- LeetCode Plus One Java版解题报告
- JAVA 语言客户信息管理系统解题报告
- POJ 1007 DNA Sorting [解题报告] Java
- POJ 1008 Maya Calendar [解题报告] Java
- 第四章:Linear Models for Classification
- 信号及信号处理
- 171.View the Exhibit and examine the command used to create the ZONEDATA table.
- django 学习网址
- 【Linux系统编程】进程间通信--消息队列
- HDU_2055解题报告(JAVA)
- Java EE 笔记三
- 设置网址导航为首页原来也可以赚点零花钱
- win32和MFC下如何使用控制台窗口
- 修改外部css样式
- unicode 与 utf-8
- 常用五大算法详细介绍
- HDU-1992-Tiling a Grid With Dominoes-4列n行的骨牌-轮廓线DP
- SqlSugar 高性能ORM 2.4 性能超Dapper 5% 和原生一样