杭电2042 2044 2019 2020-2022

2042.

#include<iostream>
#include<string>
using namespace std;
int digui(int x){
    if (x == 0)
        return 3;
     else
         return (digui(x-1)-1)*2;
}
int main()
{
    int n,m;
    while (cin >> n){
        while (n--){
            cin >> m;
            cout << digui(m) << endl;
        }
    }

}


2044

#include<iostream>
#include<string>
using namespace std;
int main()
{
    int n,a,b;
    long long int step[51];
    step[1] = 1;
    step[2] = 2;
    for (int i = 3; i < 51; i++)
        step[i] = step[i-1] + step[i - 2];
    while (cin >> n){
        while (n--){
            cin >> a>>b;            
            cout << step[b - a]<<endl;
        }
    }
    return 0;
}

2019.

#include<iostream>
#include<string>
using namespace std;

int main()
{
    int n,m,x;
    int a[100];
    while (cin >> n>>m){
        if (n == 0 && m == 0)
            return -1;
        for (int i = 0; i < n; i++)
        {
            cin >> x; a[i] = x;
        }
        for (int j = 0; j < n; j++)
        {
            if (m >= a[j] && m <= a[j + 1])
            {
                for (int b = n ; b >= j + 1; b--)
                {
                    a[b ] = a[b-1];
                }
                a[j + 1] = m;
                break;
            }
        }
        for (int i = 0; i < n; i++)
        {
            cout << a[i] << " ";
        }
        cout << a[n] << endl;
    }
    return 0;

}

2020.

#include<iostream>
#include<string>
using namespace std;

int main()
{
    int n,x,temp;
    int a[100];
    while (cin >> n)
    {
        if (n == 0)
            return -1;
        for (int i = 0; i < n; i++)
        {
            cin >> x;
            a[i] = x;
        }
        for (int i = 0; i < n - 1; i++)
            for (int j = n - 1; j > i; j--)
            {
                if (abs(a[j])>abs(a[j - 1]))
                {
                    temp = a[j];
                    a[j] = a[j - 1];
                    a[j - 1] = temp;
                }
            }
        for (int i = 0; i < n-1; i++){
            cout << a[i] << " ";
        }
        cout << a[n - 1] << endl;
    }

}


2021.

#include<iostream>
#include<string>
using namespace std;

int main()
{
    int n, sum=0;
    int a[100];
    while (cin >> n)
    {
        if (n == 0)
            return -1;
        for (int i = 0; i < n; i++){
            cin >> a[i];

                sum += a[i]/100;
                a[i] = a[i] % 100;

                sum += a[i] / 50;
                a[i] = a[i] % 50;

                sum += a[i] / 10;
                a[i] = a[i] % 10;
     
                sum += a[i] / 5;
                a[i] = a[i] % 5;

                sum += a[i] / 2;
                a[i] = a[i] % 2;
            
                sum += a[i] / 1;        
            
        
        }
            cout << sum << endl;
            sum = 0;     
    }
}

2022.

#include<iostream>
#include<string>
using namespace std;

int main()
{
    int n, m,x;
    
    int max,Ix=0,Iy=0;
    while (cin >> m>>n)
    {
        max = 0;
        Ix = 0, Iy = 0;
        for (int i =0; i <m; i++)
            for (int j = 0; j <n; j++)
            {
                cin >> x;
                if (abs(x)>abs(max))
                {
                    max = x;
                    Ix = i + 1;
                    Iy = j + 1;
                }
            }
    
        cout << Ix << " " << Iy << " " << max << endl;
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值