zoukankan      html  css  js  c++  java
  • woj1002-Genesis woj1003-birthofnoah woj1004-noah's ark


    title: woj1002-Genesis
    date: 2020-03-05
    categories: acm
    tags: [acm,woj]

    输入输出考虑一下。easy

    #include <iostream>
    #include <string>
    #include<cctype>
    using namespace std;
    
    // 考虑换行.最后 .和字母在一起不考虑。cin空格截断,刚好
    
    int main (){
        int first=1,cnt=0;
        string s;
        while(cin>>s){  //EOF   考虑换行,换行后输出上一组的cnt.first=1表示第一行
            if(isdigit(s[0])){
                if (first)
                { cout<<s<<" "; first=0;}
                else{
                cout<<cnt<<endl; cnt=0;cout<<s<<" "; }
            }
            else if(isalpha(s[0])) cnt++;   //s[0] >= 'a' && s[0] <= 'z') || (s[0] >= 'A' && s[0] <= 'Z')
        }
        cout<<cnt<<endl;  //EOF
        return 0;
    }
    

    title: woj1003-birthofnoah
    date: 2020-03-04
    categories: acm
    tags: [acm,woj,数据结构]

    简单题。用到map,pair,typedef,iterater。
    好久没做,生疏了好多。

    description:略

    #include<map>
    #include<cstdio>
    #include<cstring>
    #include<iostream>
    
    using namespace std;
    
    typedef pair<int,int> info; //ancestor,age
    map<string,info> family = {{"Adam",make_pair(1,930)},{"Seth",make_pair(2,912)},
    {"Enosh",make_pair(3,905)},{"Kenan",make_pair(4,910)},
    {"Mahalalel",make_pair(5,895)},{"Jared",make_pair(6,962)},{"Enoch",make_pair(7,365)},{"Methuselah",make_pair(8,969)},
    {"Lamech",make_pair(9,777)},{"Noah",make_pair(10,-1)},{"Shem",make_pair(11,-1)},{"Ham",make_pair(11,-1)},{"Japheth",make_pair(11,-1)}};
    
    /*好像struct更简单。但是查起来麻烦
    struct people {
    	string name[20];
    	int ancestor;
    	int old;
    }
    */
    
    void initial(){
        //复习一下
        //info p;
        //map<string,info> person;
        //p=make_pair(1,930); //p.first,p.second
        //person.insert(make_pair("Adam",p));
        
        return;
    }
    
    int main(){
        /*
        string line;
        while(getline(cin,line,'#'))
        {cout <<line;
        fflush(stdin);
        }
        */
        //initial();
        //char name1[15],name2[15];
        string name1,name2;
        map<string,info>::iterator iter1,iter2;
        while(cin>>name1>>name2)    //cin空格截断.getline可以一行
        {
            //  if(family.count(name1)>0)  必定存在,不判断
            iter1=family.find(name1);
            iter2=family.find(name2);
            if(iter1->second.first==-1||iter2->second.first==-1)  //注意map用-> pair用.
                cout<<"No enough information"<<endl;
    		else if(iter1->second.first<iter2->second.first)
    			cout<<"Yes"<<endl;
    		else
    			cout<<"No"<<endl;
     
    		if(iter1->second.second==-1||iter2->second.second==-1)
    			printf("No enough information
    ");
    		else if(iter1->second.second>iter2->second.second)
    			printf("Yes
    ");
    		else
    			printf("No
    ");
        }
        return 0;
    }
    
    

    title: woj1004-noah's ark
    date: 2020-03-05
    categories: acm
    tags: [acm,woj]

    简单题。
    注意浮点数的处理,用eps 1e-9.注意除法变乘法 a/b=6__a=6*b

    description:略

    // meters =100 cm  1 inch= 2.54cm  feet=0.3048 m  cubits 45.72cm
    // meters/centimeters/inches/cubits/feet 
    #include<iostream>
    #include <cmath>
    const double eps=1e-9;
    
    using namespace std;
    
    //l==w 则spin。否则, Its length to width ratio of exactly six to one provided excellent stability on the high seas.
    // fbs abs 求绝对值 cmath
    
    double trans(double l,string unit){
        if (unit[2]=='t')
            l*=100;
        else if(unit[2]=='c')
            l*=2.54;
        else if(unit[2]=='b')
            l*=45.72;
        else if(unit[2]=='e')
            l*=30.48;
        return l;
    }
    
    int main(){
        string l,w,h;
        int flag=0;
        double ll,ww,hh;
        while(cin>>ll){
            cin>>l>>ww>>w>>hh>>h;
            /*
            if(!flag)
                flag=1;
            else
                cout<<endl;
                */
            ll=trans(ll,l);
            ww=trans(ww,w);
            if(fabs(ll-ww)<eps)
                cout<<"Spin"<<endl;
            else if(fabs(ll-6.0*ww)<eps)   // 考虑 /0。之前先判断==0,没考虑全。
                cout<<"Excellent"<<endl;
            else
                cout<<"Neither"<<endl;
                cout<<endl;
    
        }
        return 0;
    }
    
  • 相关阅读:
    GJM :用JIRA管理你的项目(三)基于LDAP用户管理 [转载]
    GJM :用JIRA管理你的项目(二)JIRA语言包支持及插件支持 [转载]
    GJM : 用JIRA管理你的项目(一)JIRA环境搭建 [转载]
    javascripct导图
    Sublime Text 中使用Git插件连接GitHub
    使用webstorm上传代码到github
    jQuery.ajax()的一些例子
    jQuery.ajax()
    prefix和unprefix
    MVC , MVP , MVVM【转 阮一峰的网络日志】
  • 原文地址:https://www.cnblogs.com/lqerio/p/13485234.html
Copyright © 2011-2022 走看看