当前位置:网站首页>Exercise 7-4 find out the elements that are not common to two arrays (20 points)
Exercise 7-4 find out the elements that are not common to two arrays (20 points)
2022-07-04 09:47:00 【skeet follower】
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 1
The code is as follows :
#include<stdio.h>
int main()
{
int n1,n2,flag=0,i,j,m=0;
int a[21],b[21],c[30];
scanf("%d",&n1);
for(i=0;i<n1;i++){
scanf("%d",&a[i]);
}
scanf("%d",&n2);
for(i=0;i<n2;i++){
scanf("%d",&b[i]);
}
for(i=0;i<n1;i++){
for(j=0;j<n2;j++){
if(a[i]==b[j]){
flag++;
break;
}
}
if(flag==0){
c[m]=a[i];
m++;
}
flag=0;
}
for(i=0;i<n2;i++){
for(j=0;j<n1;j++){
if(b[i]==a[j]){
flag++;
break;
}
}
if(flag==0){
c[m]=b[i];
m++;
}
flag=0;
}
printf("%d",c[0]);
for(i=1;i<m;i++){
for(j=0;j<m;j++){
if(c[i]==c[j]){
break;
}
}
if(i==j){
printf(" %d",c[i]);
}
}
return 0;
}
边栏推荐
- C # use gdi+ to add text with center rotation (arbitrary angle)
- Kotlin 集合操作汇总
- C语言指针面试题——第二弹
- How do microservices aggregate API documents? This wave of show~
- Log cannot be recorded after log4net is deployed to the server
- Hands on deep learning (45) -- bundle search
- Flutter 小技巧之 ListView 和 PageView 的各種花式嵌套
- C # use gdi+ to add text to the picture and make the text adaptive to the rectangular area
- 165 webmaster online toolbox website source code / hare online tool system v2.2.7 Chinese version
- libmysqlclient.so.20: cannot open shared object file: No such file or directory
猜你喜欢
Log cannot be recorded after log4net is deployed to the server
品牌连锁店5G/4G无线组网方案
C语言指针经典面试题——第一弹
C # use ffmpeg for audio transcoding
Hands on deep learning (45) -- bundle search
2022-2028 global gasket plate heat exchanger industry research and trend analysis report
2022-2028 global protein confectionery industry research and trend analysis report
2022-2028 global tensile strain sensor industry research and trend analysis report
Hands on deep learning (40) -- short and long term memory network (LSTM)
Latex download installation record
随机推荐
Regular expression (I)
How can Huawei online match improve the success rate of player matching
Investment analysis and prospect prediction report of global and Chinese high purity tin oxide Market Ⓞ 2022 ~ 2027
Global and Chinese market of bipolar generators 2022-2028: Research Report on technology, participants, trends, market size and share
浅谈Multus CNI
Development trend and market demand analysis report of high purity tin chloride in the world and China Ⓔ 2022 ~ 2027
Pueue data migration from '0.4.0' to '0.5.0' versions
How web pages interact with applets
Hands on deep learning (35) -- text preprocessing (NLP)
2022-2028 global tensile strain sensor industry research and trend analysis report
System.currentTimeMillis() 和 System.nanoTime() 哪个更快?别用错了!
Fabric of kubernetes CNI plug-in
`Example of mask ` tool use
Launpad | 基礎知識
Normal vector point cloud rotation
Advanced technology management - how to design and follow up the performance of students at different levels
Intelligent gateway helps improve industrial data acquisition and utilization
Basic data types in golang
H5 audio tag custom style modification and adding playback control events
Analysis report on the production and marketing demand and investment forecast of tellurium dioxide in the world and China Ⓣ 2022 ~ 2027