发布网友 发布时间:2022-08-19 11:29
共1个回答
热心网友 时间:2023-10-24 00:14
#include <stdio.h>
#include<string.h>
void main() {
int nArr[10] = {5,7,3,8,6},nBrr[5] = {7,3,9,1};
int nA = 0,nB = 0,i,j;
while(nArr[nA] != 0) nA++; // nA,nB中分别保存数组nArr和nBrr中的元素个数
while(nBrr[nB] != 0) nB++;
for(i = 0;i < nA;i++) {
for(j = 0;j < nB;j++)
if(nArr[i] == nBrr[j])
nBrr[j] = 0;
}
for(j = 0;j < nB;j++) {
if(nBrr[j] != 0) {
nArr[nA] = nBrr[j];
nA++;
}
}
for(i = 0;i < nA;i++) printf("%d ",nArr[i]);
printf("\n");
}