你的思路不清晰,num1是田忌的马,num2是国王的马,qsort之后,对每一个num1中的元素,都在num2找到一个比它小的元素匹配 就行了
qsort(num1,n,sizeof(num1[0]),comp);
qsort(num2,n,sizeof(num2[0]),comp);
int index1=0,index2=0,win=0;
while(index1{
if (num1[index1]>num2[index2])
{
win++;
printf("match: Tianji %d and King %d.. total win: %d ",num1[index1],num2[index2],win)
index1++,index2++;
}
else index1++;
}