|
|
вернуться в форумWhat is wrong in this code????????Please help me #include<iostream.h> int n; int nal[100]; int mass[100][2]; int del(); void main(){ cin >> n; int j; for(int i=0;i<n;i++) nal[i]=0; for(i=0;i<n;i++) { cin >> mass[i][0]; cin >> mass[i][1]; if(mass[i][1]<mass[i][0]) { int t=mass[i][1]; mass[i][1]=mass[i][0]; mass[i][0]=t; } } for(i=0;i<n-1;i++) for(j=0;j<n-1;j++) if(mass[j][0]>mass[j+1][0]) { int t1=mass[j][0]; int t2=mass[j][1]; mass[j][0]=mass[j+1][0]; mass[j][1]=mass[j+1][1]; mass[j+1][0]=t1; mass[j+1][1]=t2; } while(del()); j=0; for(i=0;i<n;i++) if(nal[i]==0) j++; cout << j<<"\n"; for(i=0;i<n;i++) if(nal[i]==0) cout<<mass[i][0]<<" "<<mass[i][1]<<"\n"; } int del(){ int quan=0; int nquan; int thr; for(int i=0;i<n;i++) if(nal[i]==0) { nquan=0; for(int j=0;j<n;j++) if((nal[j]==0)&&(j!=i)) if(((mass[j][0]>=mass [i][0])&&(mass[j][0]<mass[i][1])) ||((mass[j][1]>mass[i] [0])&&(mass[j][1]<=mass[i][1])) ||((mass[j][0]<=mass [i][0])&&(mass[j][1]>=mass[i][1]))) nquan++; if(nquan>quan) { quan=nquan; thr=i; } } if(quan!=0) { nal[thr]=1; return 1; } return 0; } Sorry now i know where is my error |
|
|