NYOJ-a letter and a number-215

Source: Internet
Author: User
A letter and a number time limit: 3000 MS | memory limit: 65535 KB difficulty: 1
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 shoshould output the result of y + f (x ).

Input
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 ).
Output
For each case, you shoshould the result of y + f (x) on a line
Sample Input
6R 1P 2G 3r 1p 2g 3
Sample output
191810-17-14-4
 
    
#include<stdio.h>int main(){    int n;    scanf("%d",&n);    getchar();    int a;    char b;      while(n--){int sum=0;scanf("%c %d",&b,&a);if(b>='A'&&b<='Z'){sum=b-'A'+1+a;printf("%d\n",sum);getchar(); }if(b>='a'&&b<='z'){sum=-b+96+a;printf("%d\n",sum);getchar();}                   }    return 0;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.