0分求助
查看原帖
0分求助
571265
Infinity_Fantasy楼主2024/7/9 08:26

抛开 n=3n=3 的情况先不说,为什么 n=1n=1 的时候还是对不了

#include<bits/stdc++.h>
using namespace std;
int n,m,cnt;
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(i==1) cout<<++cnt<<" ";
			else if(i==2){
				if(j&1) cout<<++cnt<<" ";
				else cout<<"-1 ";
			}else if(i==3){
				if(j%3==0) cout<<"-1 ";
				else cout<<++cnt<<" ";
			}
		}
		cout<<"\n";
	}
	printf("%d\n",cnt);
	return 0;
}
2024/7/9 08:26
加载中...