当前位置:网站首页>找出不是两个数组共有的元素
找出不是两个数组共有的元素
2022-06-22 08:02:00 【好好学吧867】
给定两个整型数组,本题要求找出不是两者共有的元素。
输入格式:
输入分别在两行中给出两个整型数组,每行先给出正整数N(≤20),随后是N个整数,其间以空格分隔。
输出格式:
在一行中按照数字给出的顺序输出不是两数组共有的元素,数字间以空格分隔,但行末不得有多余的空格。题目保证至少存在一个这样的数字。同一数字不重复输出。
输入样例:
10 3 -5 2 8 0 3 5 -15 9 100
11 6 4 8 2 6 -5 9 0 100 8 1
输出样例:
3 5 -15 6 4 1代码:
#include <stdio.h>
int main(){
int a[20],b[20],c[40],i,j,k,n,m,num=0,f=0;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
scanf("%d",&m);
for(i=0;i<m;i++)
scanf("%d",&b[i]);
for(i=0;i<n;i++){
for(j=0;j<m;j++)
if(a[i]==b[j])
break;
if (j==m)
c[num++]=a[i];
}
for(i=0;i<m;i++){
for(j=0;j<n;j++)
if(b[i]==a[j])
break;
if (j==n)
c[num++]=b[i];
}
f=0;
for(i=0;i<num;i++){
for(j=0;j<i;j++)
if(c[i]==c[j]) break;
if(j==i){
if(f!=0) printf(" ");
printf("%d",c[i]);
f++;
}
}
return 0;
}边栏推荐
- Orientdb batch execute SQL
- (9)顺序队列与栈队列
- Mt4/mql4 getting started to proficient in foreign exchange EA automatic trading tutorial - common functions of MQL language
- lr 2022超详细安装教程「最新」
- Mt4/mql4 getting started to proficient in foreign exchange EA automatic trading tutorial - special identification of the K line on the chart
- Cocoapods problem record
- Master data management system
- Characteristics of industrial Internet
- Wx applet vant UI call interface to realize two-level cascade
- LNMP environment setup
猜你喜欢

Mt4/mql4 getting started to mastering EA tutorial lesson 8 - common functions of MQL language (VIII) - common time function

QT 自定义组合控件(类提升功能)

Model electricity experiment -- Experiment 1 transistor common emitter single transistor amplifier

Skills required for O & M automation?

Microsoft Remote Desktop 10.7.6正式版
![[普通物理]波的能量与干涉](/img/fe/066aa9e8ed776b8f069b59b7123367.png)
[普通物理]波的能量与干涉

模电实验——实验一 晶体管共射极单管放大器

Orientdb batch execute SQL

【宋红康 MySQL数据库 】【高级篇】【06】MySQL的逻辑架构

Vue page caching problem solving (keep alive + page level routing guard + lifecycle activated)
随机推荐
对于mysql中数据为NULL引发的一些问题和思考
模電實驗——實驗二 JFET共源極放大電路
【Oracle 数据库】奶妈式教程 day11 数值函数
关于菲涅尔现象
Semaphore
Mt4/mql4 getting started to be proficient in EA tutorial lesson 6 - common functions of MQL language (VI) - common order function
Some suggestions on Oracle SQL query return optimization
Multiple ways for idea to package jars
Asynchronous sending and receiving of message passing based concurrent programming (MPI)
QT QtableView的使用示例
ConfigManager JsonToObject
The significance of code coverage testing to programming white and its application
Website sharing of program ape -- continuous update
MySQL view
A glimpse of easy rule
Cocoapods problem record
MySQL 8.0 under Linux forgets the password
力扣(LeetCode)172. 阶乘后的零(2022.06.21)
什么是分布式事务
Design skills of common table structure in database design