杭电2055 ,注意scanf的细节用法,

#include<stdio.h>
#include<string.h>
int main()
{
    char str;
    int a,b,n;
    while(scanf("%d",&n)!=EOF)
    {

        for(a=0;a<n;a++)
        {
            getchar();//不加getchar();只能输入三组数据,scanf不会接收空行;
            scanf("%c",&str);
            scanf("%d",&b);
            if(str>=‘a‘&&str<=‘z‘)
                printf("%d",b-(str-‘a‘+1));
            else if(str>=‘A‘&&str<=‘Z‘)
                printf("%d",b+(str-‘A‘+1));
            printf("\n");
        }
    }
    return 0;
}
时间: 2024-10-21 20:31:02

杭电2055 ,注意scanf的细节用法,的相关文章

杭电2055

#include<stdio.h> int main() { int num,y,x; char k; while(scanf("%d",&num)!=EOF) { while(num--) { scanf(" %c%d",&k,&y); if(k>='A'&&k<='Z') x=k-64; else x=-(k-96); printf("%d\n",x+y); } } } 注意这种

杭电2055 另一种

可以用C++来写,就可以回避这个问题 #include<iostream> using namespace std; int main() { int num; char k; int y,x; while(cin>>num) { while(num--) { cin>>k>>y; if(k>='A'&&k<='Z') x=k-64; else x=-(k-96); cout<<x+y<<endl; } }

HDU 4937 (杭电多校 #7 1003题)Lucky Number(瞎搞)

题目地址:HDU 4937 多校的题以后得重视起来...每道题都错好多次...很考察细节.比如这道....WA了无数次.... 这题的思路自己真心想不到...这题是将进制后的数分别是1位,2位,3位和更多位的分开来计算. 当是1位的时候,显然只有3到6,此时只能是-1 当是2位的时候,可以转换成一元一次方程求解 当是3位的时候,可以转换成一元二次方程求解 当是4位的时候,此时最多也只有7000个数,7000^3接近1e12.所以剩下的直接枚举进制数来判断即可. 代码如下: #include <i

杭电 1536(尼姆博弈)

S-Nim <span size="+0"><strong><span style="font-family:Arial;font-size:12px;color:green;FONT-WEIGHT: bold">Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4479 

杭电 2710(水题)

Max Factor <span size="+0"><strong><span style="font-family:Arial;font-size:12px;color:green;FONT-WEIGHT: bold">Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s):

杭电 HDU ACM 1025 Constructing Roads In JGShining&#39;s Kingdom

Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 17732    Accepted Submission(s): 5023 Problem Description JGShining's kingdom consists of 2n(n is no mo

杭电 1850(尼姆博弈)

Being a Good Boy in Spring Festival Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4649    Accepted Submission(s): 2774 Problem Description 一年在外 父母时刻牵挂 春节回家 你能做几天好孩子吗 寒假里尝试做做下面的事情吧 陪妈妈逛一次菜场 悄悄

杭电dp题集,附链接

Robberies 点击打开链接 背包;第一次做的时候把概率当做背包(放大100000倍化为整数):在此范围内最多能抢多少钱  最脑残的是把总的概率以为是抢N家银行的概率之和- 把状态转移方程写成了f[j]=max{f[j],f[j-q[i].v]+q[i].money}(f[j]表示在概率j之下能抢的大洋); 正确的方程是:f[j]=max(f[j],f[j-q[i].money]*q[i].v)  其中,f[j]表示抢j块大洋的最大的逃脱概率,条件是f[j-q[i].money]可达,也就是

hdu 1016 Prime Ring Problem DFS解法 纪念我在杭电的第一百题

Prime Ring Problem Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 29577    Accepted Submission(s): 13188 Problem Description A ring is compose of n circles as shown in diagram. Put natural num