首页 > 学院 > 开发设计 > 正文

1100. Mars Numbers (20)

2019-11-11 05:02:48
字体:
来源:转载
供稿:网友

题目:https://www.patest.cn/contests/pat-a-PRactise/1100

代码:

#include<cstdio>  #include<cstring>  #include<cstdlib> #include<cmath>#include<map>#include<string>#include<iostream>#include<algorithm>  using namespace std; string a[13]={"tret","jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec" };string b[13]={"tret", "tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};string f[170];int main()  {   	map<string,int> mp;	for(int i=0;i<13;i++){	  mp[a[i]]=i;	  mp[b[i]]=i*13;	  f[i]=a[i];	  f[i*13]=b[i];	}	for(int i=1;i<13;i++){		for(int j=1;j<13;j++){		  string temp=b[i]+" "+a[j];		  mp[temp]=i*13+j;		  f[i*13+j]=temp;		}	}	int n;	scanf("%d%*c",&n);	while(n--){	   string str;	   getline(cin,str);	   if(str[0]>='0'&&str[0]<='9'){	      int num=0;		  for(int i=0;i<str.length();i++){		     num=num*10+(str[i]-'0');		  }		  cout<<f[num]<<endl;	   }else{	      cout<<mp[str]<<endl;	   }	}    system("pause");  }                  


上一篇:字符串问题(四)

下一篇:删数问题

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表