原来用的是for循环,后面改为while,但都没有办法把8组数据全部输入,循环一半就终止了。
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
int w,x,h;
int q;
int ans=0;
cin>>w>>x>>h>>q;
int a[w][x][h];
memset(a,0,sizeof(a));
while(q--)
{
int x1,y1,z1,x2,y2,z2;
cin>>x1>>y1>>z1>>x2>>y2>>z2;
for(int j=x1;j<=x2;j++)
{
for(int p=y1;p<=y2;p++)
{
for(int k=z1;k<=z2;k++)
{
if(a[j][p][k]==0)
ans++;
a[j][p][k]=1;
}
}
}
}
int o=w*x*h;
cout<<o-ans<<endl;
return 0;
}