杭电 2055 An easy problem
题目
杭电 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;
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
我的代码:这段一直过不了,检查不出错,无奈之下switch了一大串,终于通过了,不过还想求教这段到底哪里有问题,
#include
int main()
{
\x05int a,s,i;
\x05char z;
while(scanf("%d",&a)!=EOF)
{
\x05for(i=0;i='a'&&z='A'&&z
答案
这是我的ac码
我觉得可能是你的输入控制有问题吧,没有将换行符去掉
#include
int main()
{
int a,c;
char b;
scanf("%d",&a);
while(a--)
{
getchar();*********去掉换行符,有整数有有字符的时候要注意的.
b=getchar();
scanf("%d",&c);
if(b>='a') printf("%d\n",'a'-1-b+c);
else printf("%d\n",b-'A'+1+c);
}return 0;
}
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
最新试题
热门考点
- Should human be cloned Problems with cloning?
- 达尔文曾经说过什么也是一种自然之道?
- 游泳池里的水有多少立方米?
- 哥白尼是那个国家的人
- 若40个数据的平方和是56,平均数是(根号2)/2,则这组数据的方差是___标准差是____
- 万有引力定律是什么?
- 关于非金属元素Si,N,S,CI的叙述正确的是A通常情况下单质均为气体B在自然界中都存在游离态C都有含氧酸
- 化合反应举例.要求有三种物质参加反应的,最好比较好理解的例子
- 分苹果,若每人分5个,则剩下12个苹果,若每人分8个,则有一人分不到.求人数和苹果的个数
- 晶体的形状由什么决定