- 描述
-
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).- 输入
-
On the first line, contains a number T(0
输出 - for each case, you should the result of y+f(x) on a line
- 样例输入
-
6 R 1 P 2 G 3 r 1 p 2 g 3
- 样例输出
-
19 18 10 -17 -14 -4
-
代码:
[objc] view plaincopyprint?
- #include
int main() - { int t,y;
- char ch; scanf("%d",&t);
- while(t--) {
- getchar(); //注意字符输入时可能出现的问题,否则ch可能会接收'\n'; scanf("%c%d",&ch,&y);
- if(ch>='a'&&ch<='z') printf("%d\n",y-(ch-'a'+1));
- else printf("%d\n",y+(ch-'A'+1));
- } return 0;
- }
- #include
- <script type="text/java script">BAIDU_CLB_fillSlot("771048");
- 点击复制链接 与好友分享! 回本站首页 <script> function copyToClipBoard(){ var clipBoardContent=document.title + '\r\n' + document.location; clipBoardContent+='\r\n'; window.clipboardData.setData("Text",clipBoardContent); alert("恭喜您!复制成功"); }
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];