天天看点

The Famous Clock

时间限制:1000 ms  |  内存限制:65535 kb

难度:1

<dl>

<dt>描述 </dt>

<dd>

mr. b, mr. g and mr. m are now in warsaw, poland, for the 2012’s acm-icpc world finals contest. they’ve decided to take a 5 hours training every day before the contest.

also, they plan to start training at 10:00 each day since the world final contest will do so. the scenery in warsaw is so attractive that mr. b would always like to take a walk outside for a while after breakfast. however, mr. b have to go back before training

starts, otherwise his teammates will be annoyed. here is a problem: mr. b does not have a watch. in order to know the exact time, he has bought a new watch in warsaw, but all the numbers on that watch are represented in roman numerals. mr. b cannot understand

such kind of numbers. can you translate for him?

<dt>输入</dt>

<dd>each test case contains a single line indicating a roman numerals that to be translated. all the numbers can be found on clocks. that is, each number in the input represents an integer between 1 and 12. roman numerals are expressed by strings consisting

of uppercase ‘i’, ‘v’ and ‘x’. see the sample input for further information.</dd>

<dt>输出</dt>

<dd>for each test case, display a single line containing a decimal number corresponding to the given roman numerals.</dd>

<dt>样例输入</dt>

</dd>

<dt>样例输出</dt>

</dl>

运行时间:2012-10-05 19:47:00  |  运行人:huangyibiao

view sourceprint?

<code>01.</code><code>#include &lt;string&gt;</code>

<code>02.</code><code>#include &lt;iostream&gt;</code>

<code>03.</code><code>using</code><code>namespace</code>

<code>std;</code>

<code>04.</code> 

<code>05.</code><code>int</code><code>main()</code>

<code>06.</code><code>{</code>

<code>07.</code><code>string s;</code>

<code>08.</code><code>int</code><code>count = 0;</code>

<code>09.</code><code>while</code><code>(cin &gt;&gt; s)</code>

<code>10.</code><code>{</code>

<code>11.</code><code>cout &lt;&lt;</code><code>"case "</code>

<code>&lt;&lt; ++count  &lt;&lt;</code><code>": "</code><code>;</code>

<code>12.</code><code>if</code><code>(s ==</code><code>"i"</code><code>)</code>

<code>13.</code><code>cout &lt;&lt;</code><code>"1\n"</code><code>;</code>

<code>14.</code><code>else</code><code>if</code>

<code>(s ==</code><code>"ii"</code><code>)</code>

<code>15.</code><code>cout &lt;&lt;</code><code>"2\n"</code><code>;</code>

<code>16.</code><code>else</code><code>if</code>

<code>(s ==</code><code>"iii"</code><code>)</code>

<code>17.</code><code>cout &lt;&lt;</code><code>"3\n"</code><code>;</code>

<code>18.</code><code>else</code><code>if</code>

<code>(s ==</code><code>"iv"</code><code>)</code>

<code>19.</code><code>cout &lt;&lt;</code><code>"4\n"</code><code>;</code>

<code>20.</code><code>else</code><code>if</code>

<code>(s ==</code><code>"v"</code><code>)</code>

<code>21.</code><code>cout &lt;&lt;</code><code>"5\n"</code><code>;</code>

<code>22.</code><code>else</code><code>if</code>

<code>(s ==</code><code>"vi"</code><code>)</code>

<code>23.</code><code>cout &lt;&lt;</code><code>"6\n"</code><code>;</code>

<code>24.</code><code>else</code><code>if</code>

<code>(s ==</code><code>"vii"</code><code>)</code>

<code>25.</code><code>cout &lt;&lt;</code><code>"7\n"</code><code>;</code>

<code>26.</code><code>else</code><code>if</code>

<code>(s ==</code><code>"viii"</code><code>)</code>

<code>27.</code><code>cout &lt;&lt;</code><code>"8\n"</code><code>;</code>

<code>28.</code><code>else</code><code>if</code>

<code>(s ==</code><code>"ix"</code><code>)</code>

<code>29.</code><code>cout &lt;&lt;</code><code>"9\n"</code><code>;</code>

<code>30.</code><code>else</code><code>if</code>

<code>(s ==</code><code>"x"</code><code>)</code>

<code>31.</code><code>cout &lt;&lt;</code><code>"10\n"</code><code>;</code>

<code>32.</code><code>else</code><code>if</code>

<code>(s ==</code><code>"xi"</code><code>)</code>

<code>33.</code><code>cout &lt;&lt;</code><code>"11\n"</code><code>;</code>

<code>34.</code><code>else</code><code>if</code>

<code>(s ==</code><code>"xii"</code><code>)</code>

<code>35.</code><code>cout &lt;&lt;</code><code>"12\n"</code><code>;</code>

<code>36.</code><code>}</code>

<code>37.</code><code>return</code><code>0;</code>

<code>38.</code><code>}</code>