题名:玛雅历

题意:历法转换 。

代码:

// 1008.cpp : 定义控制台应用程序的入口点。
// #include "stdafx.h" #include <iostream>
using namespace std;
class data
{
public:
char day[];
char mon[];
char year[];
}; int main(int argc, char* argv[])
{
int num=;
cin>>num;
char temp[]={};
data *s=new data[num];
for (int i=;i<num;i++)
{
cin>>s[i].day>>s[i].mon>>s[i].year;
}
cout<<num<<endl;
string *sday=new string[];
int tmon=,tday=;
int count=;
int o=,p=;
string ma[]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
while()//计算Tzolkin历表对应一年中的天数
{
o++;
p++;
if(o>)
o=;
if(p>)
p=;
char temp[];
sprintf(temp,"%d ",o);
sday[count]=temp;
sday[count]+=ma[p-];
count++;
if(count==)
break; }
string HaabMonDic[]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
for (int i=;i<num;i++)
{
int day=atoi(s[i].day)+;
string month=s[i].mon;
int imonth=;
string year=s[i].year;
int iyear=atoi(year.c_str());
for (int j=;j<;j++)
{
if(month.compare(HaabMonDic[j])==)
{
imonth=j;
break;
}
}
int allday=iyear*+imonth*+day;
int tyear=allday/;
int tt=allday%;
if(tt==)//如果是最后一天,需要转换
{
tyear--;
tt=;
}
printf("%s %d\n",sday[tt-].c_str(),tyear);
}
delete []sday;
delete []s;
return ; }

总结:想当然,忘记要转换的历法最后一天要特殊处理,第一种历法实际上是有19个月。马虎粗心大意,哎

PKU1008的更多相关文章

随机推荐

  1. linux 挂载光盘:mount: you must specify the filesystem type

    尝试挂载光盘镜像时出现mount: you must specify the filesystem type 使用-t auto -t iso9660 或不加参数都搞不定,最后在以下链接找到解决办法: ...

  2. spring设置全局异常处理器

    1.spring设置全局异常,它的原理是向上捕获 spring.xml配置 <!--自定义全局异常处理器--> <bean id="globalExceptionResol ...

  3. C++ 指向成员函数指针问题

    成员函数指针与常规指针不同,一个指向成员变量的指针并不指向一个内存位置.通常最清晰的做法是将指向数据成员的指针看作为一个偏移量. class ru_m { public: typedef int (r ...

  4. TextMate 通用快捷键

    原来一直在Windows上使用notepad++文本编辑器,现在换了MAC,发现notepad++ 官方没有MAC版本的,在MAC上使用也有办法,只不过实在是太麻烦了. 通过查看网友的建议,发现了Te ...

  5. Python 对不均衡数据进行Over sample(重抽样)

    需要重采样的数据文件(Libsvm format),如heart_scale +1 1:0.708333 2:1 3:1 4:-0.320755 5:-0.105023 6:-1 7:1 8:-0.4 ...

  6. SAP SE11 网格布局显示

    SE11 进入数据显示界面后 在  Settings -> User Parameters,  Data Browser 页面 勾选ALV Grid display 即可.

  7. enable feature AJAX of MOSS2007

    As default, the feature AJAX of MOSS2007 is disabled, so the site web configuration file should be m ...

  8. Accessibility应用之focus篇

    最近项目中需要应用accessibility,大量使用了focus和blur,总结如下 一.设置焦点focus 如创建无障碍对话框:当一个对话框出现时,焦点应在对话框内,这样用户才可以使用键盘继续浏览 ...

  9. django orm总结[转载]

    django orm总结[转载] 转载地址: http://www.cnblogs.com/linjiqin/archive/2014/07/01/3817954.html 目录1.1.1 生成查询1 ...

  10. web.config连接字符串的一些总结

    阅读目录: DS01:数据库连接字符串的两种写法 DS02:数据库连接字符串的内容 DS01:数据库连接字符串的两种写法 1.连接字符串的两种写法: <configuration>   & ...