PAT (Advanced Level) 1100. Mars Numbers (20)
2024-09-30 19:17:57
简单题。
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std; char a[][]={
"tret","jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"
}; char b[][]={
"zzz","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"
}; int main()
{
int n; char s[];
scanf("%d",&n); getchar();
for(int i=;i<=n;i++)
{
gets(s);
if(s[]>=''&&s[]<='')
{
int num=;
for(int i=;s[i];i++) num=num*+s[i]-'';
if(num<=) printf("%s\n",a[num]);
else if(num%==) printf("%s\n",b[num/]);
else printf("%s %s\n",b[num/],a[num%]);
}
else
{
int p=-;
for(int i=;s[i];i++) if(s[i]==' ') p=i;
if(p==-)
{
int num=;
for(int i=;i<=;i++)
if(strcmp(a[i],s)==) num=i;
for(int i=;i<=;i++)
if(strcmp(b[i],s)==) num=*i;
printf("%d\n",num);
}
else
{
int num=;
char op[]; int sz=;
for(int i=;i<p;i++) op[sz++]=s[i]; op[sz]=;
for(int i=;i<=;i++)
if(strcmp(b[i],op)==) num=*i;
sz=;
for(int i=p+;s[i];i++) op[sz++]=s[i]; op[sz]=;
for(int i=;i<=;i++)
if(strcmp(a[i],op)==) num+=i;
printf("%d\n",num);
}
}
}
return ;
}
最新文章
- react native 键盘遮挡按钮点击事件
- Fedora17安装MySQL及配置
- 【转】java项目转web项目
- mysql怎么导入大文件的sql文件
- [Mysql] mysql临时表corrupt
- NOIP 2015 信息传递
- 怎样设置一个DIV在所有层的最上层,最上层DIV
- Flume practices and sqoop hive 2 oracle
- iOS关于rar解压第三方库Unrar4iOS使用总结
- noip2009提高组题解
- 【转】shell脚本调试(bash trap support bashdb )
- java集合类——Stack类
- Linux 防火墙设置,禁止某个ip访问
- RESTFul中的那些事(1)---在RESTFul中,HTTP Put和Patch操作的差别?
- C++_基础_C与C++的区别
- WEB ICON 的探讨
- Mysql经常使用命令
- Libevent源码分析—event_init()
- hdu 5122(2014北京—dp)
- Android设置竖屏