# 一道模拟题

3

eleven

one hundred and
two

output:

11

102

```  1 #include <iostream>
2 #include <cstring>
3 using namespace std;
4 struct data
5 {
6     string num;
7     int val;
8 } a[100];
9 int main()
10 {
11     int i,j,l;
12     string str[20];
13     string s[20] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen","nineteen"};
14     string p[10] = { " " ," ","twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty","ninety"} ;
15     for(i= 0; i < 20; i++)
16     {
17         a[i].num = s[i];
18         a[i].val = i;
19     }
20     int k=2;
21     for(i = 20 ; i<=27; i++,k++)
22     {
23
24         a[i].num= p[k];
25         a[i].val = k*10;
26     }
27     a[28].val=100;
28     a[28].num="hundred";
29     a[29].val=1000;
30     a[29].num="thousand";
31     a[30].val=1000000;
32     a[30].num="million";
33     /*for(i=0;i<=30;i++)
34     {
35         cout<<a[i].num<<" ";
36         cout<<a[i].val<<endl;
37     }*/
38     int t;
39     cin>>t;
40     while(t--)
41     {
42         int sum1=0;
43         for(i = 0; ; i++)
44         {
45             cin>>str[i];
46             if(cin.get() == ‘\n‘) break;
47         }
48         int mark1 = 0,mark2 = 0;
49         int sum2 = 0,sum3 = 0;
50         //int mark3 = 0,mark4 = 0;
51         for(j = 0; j <= i; j++)
52         {
53             if(str[j] == "million") mark1 = j;
54             if(str[j] == "thousand") mark2 = j;
55         }
56         if(mark1!=0&&mark2!=0)
57         {
58             for(j=0; j<=mark1; j++)
59             {
60                 for(int k=0; k<=30; k++)
61                 {
62
63                     if(str[j]==a[k].num && k < 28) sum1+=a[k].val;
64                     else if(str[j]==a[k].num && k >=28) sum1 *= a[k].val;
65                 }
66             }
67             for(j=mark1 + 1; j<=mark2; j++)
68             {
69                 for(int k=0; k<=30; k++)
70                 {
71
72                     if(str[j]==a[k].num && k < 28) sum2+=a[k].val;
73                     else if(str[j]==a[k].num && k >=28) sum2 *= a[k].val;
74                 }
75             }
76
77             for(j=mark2 + 1; j<=i; j++)
78             {
79                 for(int k=0; k<=30; k++)
80                 {
81
82                     if(str[j]==a[k].num && k < 28) sum3+=a[k].val;
83                     else if(str[j]==a[k].num && k >=28) sum3 *= a[k].val;
84                 }
85             }
86             cout<<sum1+sum2+sum3<<endl;
87         }
88         else if(mark1!=0&&mark2==0)
89         {
90             for(j=0; j<=mark1; j++)
91             {
92                 for(int k=0; k<=30; k++)
93                 {
94
95                     if(str[j]==a[k].num && k < 28) sum1+=a[k].val;
96                     else if(str[j]==a[k].num && k >=28) sum1 *= a[k].val;
97                 }
98             }
99             for(j=mark1 + 1; j<=i; j++)
100             {
101                 for(int k=0; k<=30; k++)
102                 {
103
104                     if(str[j]==a[k].num && k < 28) sum3+=a[k].val;
105                     else if(str[j]==a[k].num && k >=28) sum3 *= a[k].val;
106                 }
107             }
108             cout<<sum1+sum3<<endl;
109         }
110         else if(mark1==0&&mark2!=0)
111         {
112             for(j=0; j<=mark2; j++)
113             {
114                 for(int k=0; k<=30; k++)
115                 {
116
117                     if(str[j]==a[k].num && k < 28) sum2+=a[k].val;
118                     else if(str[j]==a[k].num && k >=28) sum2 *= a[k].val;
119                 }
120             }
121
122             for(j=mark2 + 1; j<=i; j++)
123             {
124                 for(int k=0; k<=30; k++)
125                 {
126
127                     if(str[j]==a[k].num && k < 28) sum3+=a[k].val;
128                     else if(str[j]==a[k].num && k >=28) sum3 *= a[k].val;
129                 }
130             }
131             cout<<sum3+sum2<<endl;
132         }
133         else if(mark1==0&&mark2==0)
134         {
135             for(j=0; j<=i; j++)
136             {
137                 for(int k=0; k<=30; k++)
138                 {
139
140                     if(str[j]==a[k].num && k < 28) sum3+=a[k].val;
141                     else if(str[j]==a[k].num && k >=28) sum3 *= a[k].val;
142                 }
143             }
144             cout<<sum3<<endl;
145         }
146     }
147     return 0;
148 }```

## POJ 1008 简单模拟题

e.... 虽然这是一道灰常简单的模拟题.但是米做的时候没有读懂第二个日历的计时方法.然后捏.敲完之后华丽的WA了进一个点.坑点就在一年的最后一天你是该输出本年的.e ...但是我好想并没有..看discuss里好想被坑的人还不少.总天数能直接整除260的时候.年数要减1. 不喜欢做模拟.....5555.... 附代码: #include<stdio.h>#include<string.h>#include<iostream>#include<string>

## hdu 5641 King&#39;s Phone（暴力模拟题）

Problem Description In a military parade, the King sees lots of new things, including an Andriod Phone. He becomes interested in the pattern lock screen. The pattern interface is a 3×3 square lattice, the three points in the first line are labeled as