zoukankan      html  css  js  c++  java
  • 杭电2055An easy problem

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2055

    自己的代码甚是脑残,实在没有想出其他方法来,但还是可以AC的:

    View Code
    #include <cstdlib>
    #include <iostream>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
        int t;
        cin>>t;
        while(t--)
        {
          char str;
          int c[26]={0},d[26]={0};
          int a,sum=0;
          cin>>str>>a;
          if(str=='A')
            sum=a+1;
          if(str=='B')
            sum=a+2;
          if(str=='C')
            sum=a+3;
          if(str=='D')
            sum=a+4;
          if(str=='E')
            sum=a+5;
          if(str=='F')
            sum=a+6;
          if(str=='G')
            sum=a+7;
          if(str=='H')
            sum=a+8;
          if(str=='I')
            sum=a+9;
          if(str=='J')
            sum=a+10;
          if(str=='K')
            sum=a+11;
          if(str=='L')
            sum=a+12;
          if(str=='M')
            sum=a+13;
          if(str=='N')
            sum=a+14;
          if(str=='O')
            sum=a+15;
          if(str=='P')
            sum=a+16;
          if(str=='Q')
            sum=a+17;
          if(str=='R')
            sum=a+18;
          if(str=='S')
            sum=a+19;
          if(str=='T')
            sum=a+20;
          if(str=='U')
            sum=a+21;
          if(str=='V')
            sum=a+22;
          if(str=='W')
            sum=a+23;
          if(str=='X')
            sum=a+24;
          if(str=='Y')
            sum=a+25;
          if(str=='Z')
            sum=a+26;
          if(str=='a')
            sum=a-1;
          if(str=='b')
            sum=a-2;
          if(str=='c')
            sum=a-3;
          if(str=='d')
            sum=a-4;
          if(str=='e')
            sum=a-5;
          if(str=='f')
            sum=a-6;
          if(str=='g')
            sum=a-7;
          if(str=='h')
            sum=a-8;
          if(str=='i')
            sum=a-9;
          if(str=='j')
            sum=a-10;
          if(str=='k')
            sum=a-11;
          if(str=='l')
            sum=a-12;
          if(str=='m')
            sum=a-13;
          if(str=='n')
            sum=a-14;
          if(str=='o')
            sum=a-15;
          if(str=='p')
            sum=a-16;
          if(str=='q')
            sum=a-17;
          if(str=='r')
            sum=a-18;
          if(str=='s')
            sum=a-19;
          if(str=='t')
            sum=a-20;
          if(str=='u')
            sum=a-21;
          if(str=='v')
            sum=a-22;
          if(str=='w')
            sum=a-23;
          if(str=='x')
            sum=a-24;
          if(str=='y')
            sum=a-25;
          if(str=='z')
            sum=a-26;
          cout<<sum<<endl;
        }
        system("PAUSE");
        return EXIT_SUCCESS;
    }


    继续修改ing···············

    及时修改:

    #include <cstdlib>
    #include <iostream>
    #include <stdio.h>
    using namespace std;
    
    int main(int argc, char *argv[])
    {
        int t;
        cin>>t;
        while(t--)
        {
          char str='a';
          int a,sum=0;
          cin>>str>>a;
          //printf("%d",str);
          for(char i='A';i<='Z';i++)
          {
            if(str==i)
              sum=(int)str-64+a;
          }
          for(char i='a';i<='z';i++)
          {
            if(str==i)
              sum=a+96-(int)str;
          }
          cout<<sum<<endl;
        }
        system("PAUSE");
        return EXIT_SUCCESS;
    }

    这段比上一段好多了,上一段就是脑残呀~~~~~~~~~

  • 相关阅读:
    通过AIR Native Extension在AIR应用中加入iAd广告(一) —— Flash Builder篇
    使用MonoTouch.SQLite简化用户界面开发
    常见的几种分支开发方式
    给对象增加一个简单的自定义事件机制
    WCF 4.5:配置文件更小,对ASP.NET的支持更好
    MongoDB中的Group By
    SQL Server 2012大幅增强了TSQL
    编程珠玑:对DAO层的一点修改
    《The Elements of User Experience》读书笔记
    ORM工具LLBLGen Pro 3.5发布
  • 原文地址:https://www.cnblogs.com/gkfeng/p/2620376.html
Copyright © 2011-2022 走看看