东方博弈1121~1140题解

题目开始要接触算法了,我会在暑假中尽量在学习和更新之间平衡,不会为了追求质量去刻意赶着把垃圾代码放上来,能放上来的绝大部分都是我思考后得到。

如果喜欢我的代码可以点个关注,谢谢。

1210

#include <iostream>

#include <iomanip>
using namespace std;
int main()
{
    int a[15][15];
    int n, m;
    cin >> n >> m;
    int num = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            cin >> a[i][j];
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            int judge1 = 0;
            int judge2 = 0;
            for (int k = 1; k <= m; k++)
            {
                //cout <<"a["<<i<<"]["<<k<<"]==" << a[i][k] << " " << a[i][j] << endl;
                if (a[i][k] < a[i][j])
                {
                    judge1 = 1;
                }
            }
            for (int k = 1; k <= n; k++)
            {
                //cout << "a[" << k << "][" << j << "]==" << a[k][j] << " " << a[i][j] << endl;
                if (a[k][j] > a[i][j])
                {
                    judge2 = 1;
                }
            }
            if (judge1 == 0 && judge2 == 0)
            {
                cout << i << " " << j << " " << a[i][j] << endl;
                num++;
            }
        }
    }
    if (num == 0)
    {
        cout << "not exist";
    }
    return 0;
}

1211

#include <iostream>
using namespace std;

int main(){
    int a[11],i,n,x,y;
    cin >> n;
    for(i = 0 ; i < n ; i++){
    cin >> a[i];
    }
    cin >> x;
    cin >> y;
    x--;   
    for(i = n - 1 ; i >= x ; i--){
        a[i + 1] = a[i];
    }
    
    a[x] = y;
    
    n++;
    
    for(i = 0 ; i < n ; i++){
        cout << a[i] << " ";
    }
}

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值