当前位置:网站首页>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;
}
边栏推荐
- Hands on deep learning (45) -- bundle search
- C language pointer interview question - the second bullet
- 2022-2028 global small batch batch batch furnace industry research and trend analysis report
- 2022-2028 global gasket metal plate heat exchanger industry research and trend analysis report
- Launpad | 基礎知識
- Summary of the most comprehensive CTF web question ideas (updating)
- PHP personal album management system source code, realizes album classification and album grouping, as well as album image management. The database adopts Mysql to realize the login and registration f
- Summary of reasons for web side automation test failure
- Write a mobile date selector component by yourself
- Fatal error in golang: concurrent map writes
猜你喜欢
C language pointer interview question - the second bullet
SSM online examination system source code, database using mysql, online examination system, fully functional, randomly generated question bank, supporting a variety of question types, students, teache
MySQL foundation 02 - installing MySQL in non docker version
Log cannot be recorded after log4net is deployed to the server
Hands on deep learning (46) -- attention mechanism
2022-2028 global strain gauge pressure sensor industry research and trend analysis report
Hands on deep learning (40) -- short and long term memory network (LSTM)
Mmclassification annotation file generation
Matlab tips (25) competitive neural network and SOM neural network
Four common methods of copying object attributes (summarize the highest efficiency)
随机推荐
PHP is used to add, modify and delete movie information, which is divided into foreground management and background management. Foreground users can browse information and post messages, and backgroun
华为联机对战如何提升玩家匹配成功几率
Kotlin: collection use
What are the advantages of automation?
How to display √ 2 on the command line terminal ̅? This is actually a blog's Unicode test article
Trees and graphs (traversal)
el-table单选并隐藏全选框
Write a jison parser (7/10) from scratch: the iterative development process of the parser generator 'parser generator'
2022-2028 global strain gauge pressure sensor industry research and trend analysis report
2022-2028 global optical transparency industry research and trend analysis report
Launpad | Basics
【leetcode】540. A single element in an ordered array
libmysqlclient. so. 20: cannot open shared object file: No such file or directory
PHP book borrowing management system, with complete functions, supports user foreground management and background management, and supports the latest version of PHP 7 x. Database mysql
In the case of easyUI DataGrid paging, click the small triangle icon in the header to reorder all the data in the database
法向量点云旋转
How can Huawei online match improve the success rate of player matching
H5 audio tag custom style modification and adding playback control events
Multilingual Wikipedia website source code development part II
The child container margin top acts on the parent container