#include <iostream>
#include<string.h>
using namespace std;
int f(char c){
int res;
if (c >= 'a'&&c <= 'z')
res = -(c - 'a' + 1);
else if (c >= 'A'&&c <= 'Z')
res = c - 'A' + 1;
return res;
}
int main()
{
int n;
char c;
int a;
while (cin >> n)
{
while (n--)
{
cin >> c >> a;
cout<<f(c) + a<<endl;
}
}
return 0;
}
#include<string.h>
using namespace std;
int f(char c){
int res;
if (c >= 'a'&&c <= 'z')
res = -(c - 'a' + 1);
else if (c >= 'A'&&c <= 'Z')
res = c - 'A' + 1;
return res;
}
int main()
{
int n;
char c;
int a;
while (cin >> n)
{
while (n--)
{
cin >> c >> a;
cout<<f(c) + a<<endl;
}
}
return 0;
}
本文介绍了一个简单的字符转换程序,该程序使用C++实现,并通过输入字符和整数来调整字符的ASCII值。主要功能包括区分大小写字母并进行相应的转换。
488

被折叠的 条评论
为什么被折叠?



