请问大家,为什么这个不可以呀,明明测试用例是对的
查看原帖
请问大家,为什么这个不可以呀,明明测试用例是对的
866388
adksla楼主2023/11/15 00:08
#include<stdio.h>
#include <string.h>

int main(){
	int n,m,max,x,max1=0,max2=0,sum=0;
	int a[21] = {0},b[21]={0};
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		a[x] = 1;
		if(max1<x) max1 = x;
	}
	
	for(int i=0;i<m;i++){
		scanf("%d",&x);
		b[x] = 1;
		if(max2<x) max2 = x;
	}
	if(max1>max2) max = max1;
	else max = max2;
	
	for(int i=0;i<max;i++){
		if(b[i]==a[i] && b[i]==1){
			sum++;
		}
	}
	printf("%d",sum);
} 
2023/11/15 00:08
加载中...