[HDU] [2055] An easy problem

Problem Description

Loading...

Problem Analysis

A trivial problem
I must have been intimidated by the English back then

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include<stdio.h>
int f(char c) {
	if(c>='A'&&c<='Z')
		return c-'A'+1;
	if(c>='a'&&c<='z')
		return -(c-'a'+1);
}
int main() {
	int T;
	scanf("%d",&T);
	getchar();
	while(T--) {
		char c;
		int n;
		scanf("%c %d",&c,&n);
		getchar();
		printf("%d\n",f(c)+n);
	}
	return 0;
}

Problem link: 【杭电】[2055]An easy problem

This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...