设为首页 加入收藏

TOP

NYOJ-a letter and a number
2015-07-20 17:36:31 来源: 作者: 【 】 浏览:3
Tags:NYOJ-a letter and number
a letter and a number 时间限制:3000 ms | 内存限制:65535 KB 难度:1
描述
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?
  1. #include int main()
  2. { int t,y;
  3. char ch; scanf("%d",&t);
  4. while(t--) {
  5. getchar(); //注意字符输入时可能出现的问题,否则ch可能会接收'\n'; scanf("%c%d",&ch,&y);
  6. if(ch>='a'&&ch<='z') printf("%d\n",y-(ch-'a'+1));
  7. else printf("%d\n",y+(ch-'A'+1));
  8. } return 0;
  9. }
<script type="text/java script">
<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)];
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Codeforces Round #269 (Div. 2) .. 下一篇UVALive-6665-Dragons Cruller(BF..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·PostgreSQL 索引 - (2025-12-25 22:20:43)
·MySQL Node.js 连接 (2025-12-25 22:20:41)
·SQL 撤销索引、表以 (2025-12-25 22:20:38)
·Linux系统简介 (2025-12-25 21:55:25)
·Linux安装MySQL过程 (2025-12-25 21:55:22)