C语言一道简单的题目An Easy ProblemTime Limit:1000MS Memory Limit:65536KTotal Submit:16 Accepted:7 Description 定义: f(A)=1 f(a)=-1 f(B)=2 f(b)=-2 . . . . . . f(Z)=26 f(z)=-26 读入一个字符x和一个整数y,请你求出f(x)+yInput 第

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/05 15:51:25
C语言一道简单的题目An Easy ProblemTime Limit:1000MS  Memory Limit:65536KTotal Submit:16 Accepted:7 Description 定义: f(A)=1 f(a)=-1 f(B)=2 f(b)=-2 . . . . . . f(Z)=26 f(z)=-26 读入一个字符x和一个整数y,请你求出f(x)+yInput 第

C语言一道简单的题目An Easy ProblemTime Limit:1000MS Memory Limit:65536KTotal Submit:16 Accepted:7 Description 定义: f(A)=1 f(a)=-1 f(B)=2 f(b)=-2 . . . . . . f(Z)=26 f(z)=-26 读入一个字符x和一个整数y,请你求出f(x)+yInput 第
C语言一道简单的题目
An Easy Problem
Time Limit:1000MS Memory Limit:65536K
Total Submit:16 Accepted:7
Description
定义:
f(A)=1 f(a)=-1
f(B)=2 f(b)=-2
. .
. .
. .
f(Z)=26 f(z)=-26
读入一个字符x和一个整数y,请你求出f(x)+y
Input
第一行为一个整数n,代表有几组测试数据,后面n行,每行一个字符x和一个整数y
Output
一组测试输出一个结果
Sample Input
4
R 1
P 2
G 3
r 1
Sample Output
19
18
10
-15
这是acm答题系统上的题目 各位回答尽量按照要求

C语言一道简单的题目An Easy ProblemTime Limit:1000MS Memory Limit:65536KTotal Submit:16 Accepted:7 Description 定义: f(A)=1 f(a)=-1 f(B)=2 f(b)=-2 . . . . . . f(Z)=26 f(z)=-26 读入一个字符x和一个整数y,请你求出f(x)+yInput 第
#include
int main()
{
int n;
char x;int y;
int sum;
scanf( "%d",&n );
getchar( );
for ( int i = 0; i < n; i++ )
{
scanf( "%c%d",&x,&y );
getchar( );
if ( x > 'Z')
sum = 'a' - x - 1 + y;
else
sum = x - 'A' + 1 + y;
printf( "%d\n",sum );
}
return 0;
}
不过f(r)是-18,故r 1 应该是-17,你的测试数据有问题吧?