zoukankan      html  css  js  c++  java
  • Living one day at a time (update for a long time)

    1,  http://acm.hdu.edu.cn/showproblem.php?pid=1228    2014-04-14  10:39:52

    分析:字符串处理题。。。

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<cstring>
    #include<map>
    
    using namespace std;
    
    map<string,int> mp;
    
    void init(){
        mp["zero"]=0;  mp["one"]=1;   mp["two"]=2;   mp["three"]=3;
        mp["four"]=4;  mp["five"]=5;  mp["six"]=6;   mp["seven"]=7;
        mp["eight"]=8; mp["nine"]=9;  mp["+"]=0;     mp["="]=0;
    }
    
    
    int main(){
    
        //freopen("input.txt","r",stdin);
    
        char str[1100];
        init();
    
        while(~scanf("%s",str)){
    
            int ans=0;
            int tmp1=0,tmp2=0;
            int flag=0;
            tmp1=mp[str];
            while(scanf("%s",str) && strcmp(str,"=")!=0){
                if(strcmp(str,"+")==0){
                    flag=1;
                    continue;
                }
                if(flag==0){
                    tmp1=tmp1*10+mp[str];
                }else{
                    tmp2=tmp2*10+mp[str];
                }
            }
            ans=tmp1+tmp2;
            if(ans==0)
                break;
            printf("%d
    ",ans);
        }
    
        return 0;
    }
    View Code

    2,  http://acm.hdu.edu.cn/showproblem.php?pid=1229    2014-04-14  10:48:57

    分析:easy题。。。

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<cstring>
    #include<map>
    
    using namespace std;
    
    int main(){
        
    //    freopen("input.txt","r",stdin);
    
        int a,b,k;
        while(~scanf("%d%d%d",&a,&b,&k)){
            int tmp=1;
            if(a+b==0)
                break;
            while(k!=0){
                tmp*=10;
                k--;
            }
            if(a%tmp-b%tmp==0){
                printf("-1
    ");
            }else{
                printf("%d
    ",a+b);    
            }
        }
        return 0;
    }
    View Code
  • 相关阅读:
    用U3D寻找看电视的感觉!!
    MipMap
    什么是 A 轮融资?有 B轮 C轮么?
    Java写的斗地主游戏源码
    sqlserver sp_spaceused用法
    SQL中的全局变量和局部变量(@@/@)
    SQL2008数据库导出到SQL2000全部步骤过程
    生成Insert语句的存储过程
    物理机连接虚拟机数据库
    配置sql server 2000以允许远程访问
  • 原文地址:https://www.cnblogs.com/jackge/p/3663488.html
Copyright © 2011-2022 走看看