Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:用STL的map写起来比较简单;理解啦,我开始没搞清楚map容器

Posted by mysteryzyf at 2013-06-16 14:41:54 on Problem 1008
In Reply To:用STL的map写起来比较简单 Posted by:cfxwmio03 at 2013-03-09 00:17:17
> rt.
> 
> /////////////////////////////分割线
> 
> #include <iostream>
> #include <cstdio>
> #include <string>
> #include <vector>
> #include <map>
> 
> using namespace std;
> 
> void init_dict(map<string, int> &h, map<int, string> &t)
> {
>     //Haab dictionary
>     h.insert(make_pair(string("pop"), 0));
>     h.insert(make_pair(string("no"), 1));
>     h.insert(make_pair(string("zip"), 2));
>     h.insert(make_pair(string("zotz"), 3));
>     h.insert(make_pair(string("tzec"), 4));
>     h.insert(make_pair(string("xul"), 5));
>     h.insert(make_pair(string("yoxkin"), 6));
>     h.insert(make_pair(string("mol"), 7));
>     h.insert(make_pair(string("chen"), 8));
>     h.insert(make_pair(string("yax"), 9));
>     h.insert(make_pair(string("zac"), 10));
>     h.insert(make_pair(string("ceh"), 11));
>     h.insert(make_pair(string("mac"), 12));
>     h.insert(make_pair(string("kankin"), 13));
>     h.insert(make_pair(string("muan"), 14));
>     h.insert(make_pair(string("pax"), 15));
>     h.insert(make_pair(string("koyab"), 16));
>     h.insert(make_pair(string("cumhu"), 17));
>     h.insert(make_pair(string("uayet"), 18));
> 
>     //tzolkin dictionary
>     t.insert(make_pair(1, string("imix")));
>     t.insert(make_pair(2, string("ik")));
>     t.insert(make_pair(3, string("akbal")));
>     t.insert(make_pair(4, string("kan")));
>     t.insert(make_pair(5, string("chicchan")));
>     t.insert(make_pair(6, string("cimi")));
>     t.insert(make_pair(7, string("manik")));
>     t.insert(make_pair(8, string("lamat")));
>     t.insert(make_pair(9, string("muluk")));
>     t.insert(make_pair(10, string("ok")));
>     t.insert(make_pair(11, string("chuen")));
>     t.insert(make_pair(12, string("eb")));
>     t.insert(make_pair(13, string("ben")));
>     t.insert(make_pair(14, string("ix")));
>     t.insert(make_pair(15, string("mem")));
>     t.insert(make_pair(16, string("cib")));
>     t.insert(make_pair(17, string("caban")));
>     t.insert(make_pair(18, string("eznab")));
>     t.insert(make_pair(19, string("canac")));
>     t.insert(make_pair(0, string("ahau")));
> 
> }
> 
> 
> int main(int argc, char **argv)
> {
>     map<string, int> haab;
>     map<int, string> tzolkin;
>     int n;
>     init_dict(haab, tzolkin);
> 
>     cin>>n;
>     cout<<n<<endl;
>     for(int i = 0;i < n;i++){
>         int d;
>         string m;
>         int y;
>         scanf("%d.", &d);
>         cin>>m>>y;
>         int t = y*365 + haab[m]*20 + d + 1;
>         int tt = t % 260;
>         cout<<(tt%13?tt%13:13)<<" "<<tzolkin[tt%20]<<" "<<(tt?int(t/260):int(t/260-1))<<endl;
>     }
> 
>     return 0;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator