zoukankan      html  css  js  c++  java
  • 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(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

    C/C++ AC:

     1 #include <iostream>
     2 #include <algorithm>
     3 #include <cstring>
     4 #include <cstdio>
     5 #include <cmath>
     6 #include <stack>
     7 #include <set>
     8 #include <map>
     9 #include <queue>
    10 #include <climits>
    11 #define PI 3.1415926
    12 
    13 using namespace std;
    14 int n;
    15 
    16 int main()
    17 {
    18     cin >>n;
    19     while (n --)
    20     {
    21         char letter;
    22         int number;
    23         cin >>letter >>number;
    24         if (letter >= 'A' && letter <= 'Z')
    25         {
    26             cout <<letter - 'A' + 1 + number <<endl;
    27         }
    28         else
    29         {
    30             cout <<-1 * (letter - 'a' + 1) + number <<endl;
    31         }
    32     }
    33 }
  • 相关阅读:
    AWR介绍使用
    hint使用
    部分索引类型介绍\索引重建否\索引压缩
    生成Oracle Statpack步骤
    自治事务
    append与nologging的使用
    聚簇表
    C语言杂谈——静态函数
    Qt之对话框设计——可扩展对话框
    C语言杂谈——指针篇
  • 原文地址:https://www.cnblogs.com/GetcharZp/p/9334389.html
Copyright © 2011-2022 走看看