求助(四年级小孩,学到排序真不会了)

题目总版

kabule_charlie @ 2024-11-02 22:38:13

https://www.luogu.com.cn/problem/B4037


by kabule_charlie @ 2024-11-02 22:38:42

玄关


by doujiamu @ 2024-11-02 22:46:04

@kabule_charlie 这题不是模拟吗


by zhs_TLE @ 2024-11-02 22:49:17

记几个排序板子,然后多做做题就行了\ 而且这道题是模拟呀……


by doujiamu @ 2024-11-02 22:51:58

@kabule_charlie 楼上说的对
正好睡前切个模拟
就这道题吧,代码如下,可供参考

#include<bits/stdc++.h>
using namespace std;
signed main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= n; ++ j){
            if(j == 1 || j == n || j == i)cout << '+';
            else cout << '-';
        }
        cout << '\n';
    }
    return 0;
} 

by lsd110504 @ 2024-11-02 22:57:44

#include<iostream>
using namespace std;
bool a[50][50];
int main(){
    int m;
    cin>>m;
    for(int i=1;i<=m;i++)
    {
        a[i][1]=a[i][m]=1;
    }
    for(int i=1;i<=m;i++)
    {
        a[i][i]=1;
    }
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(a[i][j])
                cout<<"+";
            else cout<<"-";
        }
        cout<<endl;
    }
    return 0;
} 

你看看能看懂吗

别忘了关注 @kabule_charlie


by lsd110504 @ 2024-11-02 22:59:12

这好像不是排序

把a[i][i]和开头结尾枚举一遍就可以了


by kabule_charlie @ 2024-11-03 22:46:57

@doujiamu 谢谢


by kabule_charlie @ 2024-11-03 22:47:54

@lsd110504 谢谢


|