月圆、笙起 @ 2018-12-19 19:18:29
#include<bits/stdc++.h>
using namespace std;
struct carpet{
int x1,y1,x2,y2;
}a[1005];
int main(){
int n,m,i,j,l,floor[1005][1005];
cin>>n>>m;
for(i=1;i<=m;i++) cin>>a[i].x1>>a[i].y1>>a[i].x2>>a[i].y2;
for(i=1;i<=m;i++) for(j=a[i].x1;j<=a[i].x2;j++) for(l=a[i].y1;l<=a[i].y2;l++) floor[j][l]++;
for(i=1;i<=n;i++) for(j=1;j<=n;j++) cout<<floor[i][j];
return 0;}
by wxy_god @ 2018-12-19 19:20:55
您这压行压得。。。
by TinyKiecoo @ 2018-12-19 19:22:32
#include<bits/stdc++.h>
using namespace std;
struct carpet {
int x1,y1,x2,y2;
} a[1005];
int n,m,i,j,l,Floor[1005][1005];
int main() {
cin>>n>>m;
for(i=1; i<=m; i++) cin>>a[i].x1>>a[i].y1>>a[i].x2>>a[i].y2;
for(i=1; i<=m; i++) for(j=a[i].x1; j<=a[i].x2; j++) for(l=a[i].y1; l<=a[i].y2; l++) Floor[j][l]++;
for(i=1; i<=n; i++) for(j=1; j<=n; j++) cout<<Floor[i][j];
return 0;
}
by TinyKiecoo @ 2018-12-19 19:23:03
不要在main函数中定义大数组,会RE
by TinyKiecoo @ 2018-12-19 19:23:25
话说您这个程序可能会超时吧
by TinyKiecoo @ 2018-12-19 19:23:46
@月圆、笙起
by _ @ 2018-12-19 19:33:48
for(i=1; i<=n; i++)
aaa
for(j=1; j<=n; j++) cout<<Floor[i][j];
aaa这里换行呢
by E_REMAL @ 2018-12-19 19:39:57
y1好像无法运行
by 月圆、笙起 @ 2018-12-19 19:47:12
额
by 月圆、笙起 @ 2018-12-19 19:48:12
#include<bits/stdc++.h>
using namespace std;
struct carpet{int x1,y1,x2,y2;}a[701];
int main(){int n,m,i,j,l,f[701][701];
cin>>n>>m;
for(i=1;i<=m;i++) cin>>a[i].x1>>a[i].y1>>a[i].x2>>a[i].y2;
for(i=1;i<=m;i++) for(j=a[i].x1;j<=a[i].x2;j++) for(l=a[i].y1;l<=a[i].y2;l++) f[j][l]++;
for(i=1;i<=n;i++){for(j=1;j<=n;j++) cout<<f[i][j]<<" ";
cout<<endl;}
return 0;}
by iotang @ 2018-12-19 19:53:56
这可怕的代码风格