求大佬康康,救救孩子吧orz
能力低微看不出错... 下载次数无了,我也无了QAQ
#include <stdio.h>
#include <stdlib.h>
int main(){
int (*scope)[2];int m=0,i,j,l=0,ans=0;
scanf("%d%d",&l,&m);
scope=(int(*)[2])malloc(2*m*sizeof(int*));//m row
scanf("%*[^\n]%*c");
//////get scopes
for(i=0;i<m;i++)
{scanf("%d%d",
&scope[i][0],&scope[i][1]);
scanf("%*[^\n]%*c");}
//////whether scopes have the same part
for(i=0;i<m-1;i++)
{for(j=i+1;j<m;j++)
{if(scope[i][1]>=scope[j][0])
{if(scope[i][1]<=scope[j][1])
{scope[i][1]=scope[j][1];}
if(scope[i][0]>=scope[j][0])
{scope[i][0]=scope[j][0];}
scope[j][0]=-1;
scope[j][1]=-1;}}}
///////calculate total scopes
for(i=0;i<m;i++)
{if(scope[i][0]!=-1)
{ans+=(scope[i][1]-scope[i][0]+1);}}
//////print out answers
printf("%d",l+1-ans);
//////free
free(scope);
return 0;
}