当前位置:网站首页>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 1sample output :
3 5 -15 6 4 1The 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 (33) -- style transfer
- Qtreeview+ custom model implementation example
- Pueue data migration from '0.4.0' to '0.5.0' versions
- C # use smtpclient The sendasync method fails to send mail, and always returns canceled
- Application of safety monitoring in zhizhilu Denggan reservoir area
- Implementing expired localstorage cache with lazy deletion and scheduled deletion
- Four common methods of copying object attributes (summarize the highest efficiency)
- el-table单选并隐藏全选框
- How can people not love the amazing design of XXL job
- 165 webmaster online toolbox website source code / hare online tool system v2.2.7 Chinese version
猜你喜欢

2022-2028 global visual quality analyzer industry research and trend analysis report

Normal vector point cloud rotation

Four common methods of copying object attributes (summarize the highest efficiency)

Daughter love in lunch box

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

2022-2028 global small batch batch batch furnace industry research and trend analysis report

Hands on deep learning (40) -- short and long term memory network (LSTM)

Daughter love: frequency spectrum analysis of a piece of music

ASP. Net to access directory files outside the project website

Baidu R & D suffered Waterloo on three sides: I was stunned by the interviewer's set of combination punches on the spot
随机推荐
Latex download installation record
Baidu R & D suffered Waterloo on three sides: I was stunned by the interviewer's set of combination punches on the spot
Log cannot be recorded after log4net is deployed to the server
Hands on deep learning (44) -- seq2seq principle and Implementation
The 14th five year plan and investment risk analysis report of China's hydrogen fluoride industry 2022 ~ 2028
lolcat
Qtreeview+ custom model implementation example
SQL replying to comments
Hands on deep learning (42) -- bi-directional recurrent neural network (BI RNN)
2022-2028 global gasket plate heat exchanger industry research and trend analysis report
Go context 基本介绍
Lauchpad x | MODE
How can Huawei online match improve the success rate of player matching
Kotlin 集合操作汇总
Hands on deep learning (III) -- Torch Operation (sorting out documents in detail)
Summary of small program performance optimization practice
Analysis report on the development status and investment planning of China's modular power supply industry Ⓠ 2022 ~ 2028
Modules golang
In the case of easyUI DataGrid paging, click the small triangle icon in the header to reorder all the data in the database
C # use gdi+ to add text with center rotation (arbitrary angle)