- C20250002's blog
直接爆并集代码(没有搞交集哦)
- 2022-10-24 12:00:10 @
#include <iostream>
using namespace std;
int bing(int a1,int b1,int a2,int b2){
int long l=max(b1,b2)-min(a1,a2);
int p[l];
for(int k=0;k<=l;k++){
if((k+min(a1,a2)<=b1&&k+min(a1,a2)>=a1)||(k+min(a1,a2)<=b2&&k+min(a1,a2)>=a2)){
p[k]=1;
}
else{
p[k]=0;
}
}
for(int k=0;k<=l;k++){
cout<<p[k];
}
return 0;
}
int main(){
cout<<"请依次输入两个集合的开始和结束"<<endl<<"格式:begin1 end1 begin2 end2"<<endl;
int long m1,n1,m2,n2;
cin>>m1>>n1>>m2>>n2;
bing(m1,n1,m2,n2);
}
糟糕透了...一定比不上某些大奆的代码呵呵