四花齐放

B4066 [GESP202412 三级] 数字替换

xizao_haoxuan @ 2024-12-24 20:40:00

#include<bits/stdc++.h>
using namespace std;
int n,k,a[100000],maxn=-100001,minn=100001;
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]>maxn)
        {
            maxn=a[i];
        }
        if(a[i]<minn)
        {
            minn=a[i];
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]>k)
        {
            a[i]=maxn;
        }
        if(a[i]<k)
        {
            a[i]=minn;
        }
    }
    for(int i=1;i<=n;i++)
    {
        cout<<a[i]<<" ";
    }
    return 0;
} 

by wangyubo1227 @ 2024-12-24 20:45:56

删前刘明


by wangyubo1227 @ 2024-12-24 20:46:17

默哀


by wangyubo1227 @ 2024-12-24 20:47:23

讨论区题解,紫衫吧@xizao_haoxuan


by xizao_haoxuan @ 2024-12-24 20:48:36

@wangyubo1227 这又不是AC代码


by xizao_haoxuan @ 2024-12-24 20:49:07

我说的是四个WA


by tyr_04 @ 2024-12-24 20:51:25

@wangyubo1227

但凡看得懂标题的都知道这是求助帖


by bsdsdb @ 2024-12-24 20:58:34

@wangyubo1227

但凡看得懂标题的都知道这是求助帖


by Tenko_awa @ 2024-12-24 21:07:34

666我是RE,老师让做的另一题你做了嘛


by xizao_haoxuan @ 2024-12-28 22:14:18

@Tenko_awa 左拉


|