2016-08-04

题源:http://acm.timus.ru/problemset.aspx?space=1&page=8  

 

ctrl+f   搜索   Ural Regional School Programming Contest 2010

1.输入数字,输出对应区间的单词,如下图

 

输入的数字 输出
from 1 to 4 few
from 5 to 9 several
from 10 to 19 pack
from 20 to 49 lots
from 50 to 99 horde
from 100 to 249 throng
from 250 to 499 swarm
from 500 to 999 zounds
from 1000 legion

越是水的题,姿势越重要!!看姿势!!

代码:

#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

int a[]={1,5,10,20,50,100,250,500,1000,2001};
char b[][8]={"few","several","pack","lots","horde","throng","swarm","zounds","legion"};
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<9;i++)
    {
        if(n>=a[i]&&n<a[i+1])
            puts(b[i]);
    }

    return 0;
}
View Code

相关文章: