• 考试四道题


    1分配任务

      (task.pas/c/cpp)

    【问题描述】

       在社会实践活动中有三项任务分别是:种树、采茶、送水。依据小组人数及男生、女生人数决定小组的接受任务,人数小于10人的小组负责送水(输出water),人数大于等于10人且男生多于女生的小组负责种树(输出tree),人数大于等于10人且男生不多于女生的小组负责采茶(输出tea)。输入小组男生人数、女生人数,输出小组接受的任务。

    【输入】

    一行两个空格隔开的数,表示小组中男生和女生的人数。

    【输出】

    输出对应的任务。

    【输入输出样例1】

    task.in

    task.out

    5 3

    water

    【数据范围】

       数据保证输入的两个整数小于等于15。

    【注释】

    本次考试不及格的同学可能会被分入其中一组哦。

    #include<iostream>
    #include<cstdio>
    //#include<cmath>
    //#include<iomanip>
    using namespace std;
    int main()
    {
       freopen("task.in","r",stdin);
       freopen("task.out","w",stdout);
        int x,y,m;
        cin>>x>>y;
        m=x+y;
        if(m<10)  cout<<"water"<<endl;
        if((m>=10)&&(x>y))  cout<<"tree"<<endl;
        if((m>=10)&&(x<=y))  cout<<"tea"<<endl;
        //cout<<setiosflags(ios::fixed)<<setprecision(1);
       return 0;
    }

    2计算距离

      (distance.pas/c/cpp)

    【问题描述】

       在平面中之角坐标系中,两个点A(x1,y1),B(x2,y2)的距离有很多种衡量方式,其中有两种很常用。

    第一种是直线距离:

    第二种叫做曼哈顿距离,公式如下:

    【输入】

    四个正整数x1,y1,x2,y2。

    【输出】

    一共两行,每行一个数。

    第一行输出直线距离。

    第二行输出曼哈顿距离。

    要求:保留两位小数。

    【输入输出样例1】

    distance.in

    distance.out

    1 1 2 2

    1.41

    2.00

    【数据范围】

    x1,y1,x2,y2都是100000以内的正整数

    #include<iostream>
    #include<cmath>
    #include<iomanip>
    #include<cstdio>
    using namespace std;
    int main()
    {
        freopen("distance.in","r",stdin);
        freopen("distance.out","w",stdout);
        double x1,x2,y1,y2,a,b;double dis1,dis2;
        cin>>x1>>y1>>x2>>y2;
        dis1=1.0*sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
        if(x1>=x2) a=x1-x2;
        else a=x2-x1;
        if(y1>=y2) b=y1-y2;
        else b=y2-y1;
        dis2=a+b;
        cout<<setiosflags(ios::fixed)<<setprecision(2);
        cout<<dis1<<endl;
        cout<<dis2<<endl;
        return 0;
    }

    3蜗牛

      (snail.pas/c/cpp)

    【问题描述】

       蒟蒻蜗牛lzh掉到了一口深井底部,但是他有梦想,他一定要爬出来!!

    已知井的深度D厘米,以及lzh每天白天能向上爬a厘米。但是最惨的在后面:lzh每天晚上睡觉的时候都会向下滑b厘米。现在是第一天早上,lzh开始向上爬,lzh想知道从今天算起,他第几天才能重见天日(爬出深井)。

    【输入】

    一行三个空格隔开的正整数D,a,b。

    【输出】

    如果lzh能爬上来,输出一个数,代表lzh第几天才能重见天日,如果lzh永远爬不上来,输出“bye bye”。

    【输入输出样例1】

    snail.in

    snail.out

    10000 6 1

    2000

    【输入输出样例2】

    snail.in

    snail.out

    7 6 6

    bye bye

    【数据范围】

    1<=D<=100000

    【注释】

    能碰到井口就算爬出深井,例如,对于10厘米的井,如果lzh能上升10厘米或10厘米以上,就算爬出深井。蜗牛的身体长度不计。

    #include <iostream>
    #include <cstdio>
    using namespace std;
    int main()
    {
        freopen("snail.in","r",stdin);
        freopen("snail.out","w",stdout);
        int depth,days,u,d;
        cin>>depth>>u>>d;
        if(u<=d&&u<depth)
            cout<<"bye bye";
        else
        {
            for(int i=1;i<=10000000;i++)
            {    
                days=i;
                depth-=u;
                if(depth<=0)
                    break;        
                depth+=d;
                if(depth<=0)
                    break;
            }
            cout<<days;
        }
    }

    4.鱼的排队

      (fivesort.pas/c/cpp)

    【问题描述】

       lxt有一项超能力,就是和焦作一中的湖里的鱼儿进行交流。

    lxt和其中的5条鱼成为了最好的朋友,他决定在某一天让这5条鱼排成一队,在湖里游行,排队的规则就是按照鱼的编号从小到大进行。

       现在lxt知道了这5条鱼的编号,想知道这5条鱼的编号从小到大排序后的结果,希望你写个程序帮助他。

    对于写过3个数排序的你来说,5条鱼的排序当然不在话下。

    【输入】

    一行,5个用空格隔开的整数。

    【输出】

    一行,从小到大排序后的整数,每个整数用1个空格隔开。

    【输入输出样例1】

    fivesort.in

    fivesort.out

    5 4 2 3 1

    1 2 3 4 5

    【输入输出样例2】

    fivesort.in

    fivesort.out

    11 33 33 22 11

    11 11 22 33 33

    【数据范围】

       保证5个整数都是1000以内的正数。

    【注释】

    本题就是传说中的附加题。

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
        freopen("fivesort.in","r",stdin);
        freopen("fivesort.out","w",stdout);
        int a,b,c,d,e,temp;
        cin>>a>>b>>c>>d>>e;
        if(a>b)  {temp=a;a=b;b=temp;}
        if(a>c)  {temp=a;a=c;c=temp;}
        if(a>d)  {temp=a;a=d;d=temp;}
        if(a>e)  {temp=a;a=e;e=temp;}
        if(b>c)  {temp=b;b=c;c=temp;}
        if(b>d)  {temp=b;b=d;d=temp;}
        if(b>e)  {temp=b;b=e;e=temp;}
        if(c>d)  {temp=c;c=d;d=temp;}
        if(c>e)  {temp=c;c=e;e=temp;}
        if(d>e)  {temp=d;d=e;e=temp;}
        cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
        fclose(stdin);fclose(stdout);
        return 0;
    }
    #include<cstdio>
    #include<iostream>
    #include<cmath>
    #include<iomanip>
    using namespace std;
    int main()
    {
        freopen("fivesort.in","r",stdin); 
        freopen("fivesort.out","w",stdout);
        int a,b,c,d,e;
        cin>>a>>b>>c>>d>>e;
        for(int i=1;i<=1000;i++)
        {
            if(i==a)cout<<i<<' ';
            if(i==b)cout<<i<<' ';
            if(i==c)cout<<i<<' ';
            if(i==d)cout<<i<<' ';
            if(i==e)cout<<i<<' ';
        }
        return 0;
    }

    附:

    ftp://172.20.6.11  

    用户名

    administrator

    密码

    administrator

    提交位置 

    ftp://172.20.6.11  

    2017文件夹

    新高一集训 文件夹

    考试程序 文件夹

  • 相关阅读:
    关于mysql主从架构master宕机
    恢复drop后的表空间
    rman 恢复drop 表空间模拟恢复
    backup controlfile 和create standby controlfile
    catalog
    rman恢复表(不完全恢复)--需要关闭数据库
    rman备份恢复
    oracle DG 启动和关闭顺序
    ASM-本地数据拷贝
    图解Java设计模式之模板模式
  • 原文地址:https://www.cnblogs.com/jzyz-lfy/p/7256161.html
Copyright © 2020-2023  润新知