100过了,但是求助
查看原帖
100过了,但是求助
997755
537wsq楼主2023/5/16 10:08
#include <stdio.h>	

int main()
{
   int l, m;
   int n;
   scanf("%d %d",&l, &m);
   int s = l + 1;
   int num[s];
   for (n = 0; n < s; n++)
   {
   	num[n] = 1;
   }
   int u,v;
   int i,j;
   for (i = 0; i < m; i++)
   {
   	for (j = 0; j < 2; j++)
   	{
       		scanf("%d %d", &u, &v);
   			for (n = u; n <= v; n++)    	
   			{
   				num[n] = 0;
   			}
   	}
   }
   int cnt = 0;
   for (n = 0; n < s; n++)
   {
   	if (num[n] == 1)
   	{
   		cnt++;
   	}
   }
   printf("%d", cnt);
   
   return 0;
} 

100分过了,但是自己运行的时候需要输六次数据才运行结束,是哪里出错了吗

500 3
150 300
100 200
470 471
150 300
100 200
470 471
298
--------------------------------
Process exited after 3.775 seconds with return value 0
请按任意键继续. . .
2023/5/16 10:08
加载中...