1044 火星数字 c++

//不知道为什么测试点2,3,4都没有通过,回头再看看

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
    string huoa[14]={"tret","jan","feb","mar","apr","may","jun","jil","aug","sep","oct","nov","dec","tam"};
    string huob[13]={"","tam","hel","maa","huh","tou","kes","hei","elo","syy","lok","mer","jou"};
    string s,ss;
    int n;
    int m=0;
    char c;
    cin>>n;
    for(int i=0;i<n;i++){
                    m=0;   //注意
        cin>>s;
        if(s[0]>='0'&&s[0]<='9'){
            int l=s.size();
            if(l==1){
                m=s[0]-'0'+0;
            }else if(l==2){
                m=(s[0]-'0')*10+s[1]-'0';
            }else{
                m=(s[0]-'0')*100+(s[1]-'0')*10+s[2]-'0';
            }
            int x,y;
            x=m/13;
            y=m%13;
            if(x!=0){
                cout<<huob[x]<<" ";
            }
            /*火星文的13、26里个位的0是不用打印*/
            /*类似的这个地方在转化为数字时也要考虑*/
            if(x!=0&&y==0){
                
            }else{
                cout<<huoa[y]<<endl;
            }
        }else{
           c=cin.get();
            if(c==' '){  //注意这时ss才是个位
                cin>>ss;
                                for(int i=0;i<13;i++){
                    if(huoa[i][0]==ss[0]&&huoa[i][1]==ss[1]&&huoa[i][2]==ss[2]){
                        m=m+i;
                    }
                }
                                for(int i=0;i<13;i++){
                    if(huob[i][0]==s[0]&&huob[i][1]==s[1]&&huob[i][2]==s[2]){
                        m=m+i*13;
                    }
                }
                cout<<m<<endl;
            }else{    //一个单词时可能<13;可能/13
                for(int i=0;i<13;i++){
                    if(huoa[i][0]==s[0]&&huoa[i][1]==s[1]&&huoa[i][2]==s[2]){
                        cout<<i<<endl;
                    }
                                        if(huob[i][0]==s[0]&&huob[i][1]==s[1]&&huob[i][2]==s[2]){
                        cout<<i*13<<endl;
                    }
                }
            }
        }
    }
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值