当前位置:网站首页>Find elements that are not common to two arrays
Find elements that are not common to two arrays
2022-06-22 08:10:00 【Study hard 867】
Given two arrays of integers , This problem requires us to find out the elements that are not in common .
Input format :
Input two arrays of integers in two lines , Give a positive integer on each line N(≤20), And then there was N It's an integer , Separated by spaces .
Output format :
In a row, output elements that are not common to two groups of numbers in the order given by the numbers , Numbers are separated by spaces , But there must be no extra space at the end of the line . The title guarantees that there is at least one such number . The same number is not output repeatedly .
sample input :
10 3 -5 2 8 0 3 5 -15 9 100
11 6 4 8 2 6 -5 9 0 100 8 1
sample output :
3 5 -15 6 4 1Code :
#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;
}边栏推荐
- Energy and interference of waves
- 【宋红康 MySQL数据库 】【高级篇】【06】MySQL的逻辑架构
- Mt4/mql4 getting started to mastering EA tutorial lesson 3 - common functions of MQL language (III) - common functions of K-line value taking
- 矩阵运算
- On Fresnel phenomenon
- Master data management system
- Mt4-mql4 language EA automatic transaction programming introduction to proficiency
- Mt4/mql4 getting started to mastering EA tutorial lesson 8 - common functions of MQL language (VIII) - common time function
- Chmod Chmod command
- Seven challenges faced by CIO in 2022 and Solutions
猜你喜欢

Skills required for O & M automation?
![[Oracle database] mammy tutorial Day12 character function](/img/77/3b3aa643b0266e709019399b17bb93.png)
[Oracle database] mammy tutorial Day12 character function

Model electricity experiment -- Experiment 2 JFET common source amplifier circuit

Orientdb batch execute SQL

Failed to access the ES installed on Tencent ECs, but the solution to accessing the ES successfully on the server

XMIND 2022 mind map active resources?

0 basic self-study STM32 (wildfire) -- what is a register?

Usage and understanding of async/await in JS

What is distributed transaction

It operation and maintenance knowledge map
随机推荐
Skills required for O & M automation?
《守望先锋》阵亡镜头、全场最佳和亮眼表现是如何设计
Dom4j+xpath parsing XML files
Leetcode 172 Zero after factorial (2022.06.21)
Design skills of common table structure in database design
[普通物理]波的能量与干涉
Mt4-mql4 language EA automatic transaction programming introduction to proficiency
Postgresql源码(56)可扩展类型分析ExpandedObject/ExpandedRecord
Modular import and export collation in JS
Common array operations in JS
MySQL backup - mysqldump
MySQL queries data within one hour
【 Oracle database】 Nursery Mother Tutorial day13 date Function
Summary of basic knowledge of Oracle database SQL statement II: data operation language (DML)
C# 接口持有结构体会导致装箱问题
【Oracle 数据库】奶妈式教程day15 DDL、DML、索引、视图、序列、死锁这一篇就够了
mapTalks:基础操作与WMS/WMTS地图服务加载
Expérience électrique en mode - - expérience 2 circuit d'amplification de source commune JFET
SQL server changes the primary key index to a non clustered index
Oracle execution plan analysis