当前位置:网站首页>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;
}边栏推荐
- The 14th five year plan and investment risk analysis report of China's hydrogen fluoride industry 2022 ~ 2028
- Write a jison parser from scratch (4/10): detailed explanation of the syntax format of the jison parser generator
- Sort out the power node, Mr. Wang he's SSM integration steps
- Fabric of kubernetes CNI plug-in
- Implementing expired localstorage cache with lazy deletion and scheduled deletion
- SQL replying to comments
- Modules golang
- Global and Chinese markets of water heaters in Saudi Arabia 2022-2028: Research Report on technology, participants, trends, market size and share
- Explanation of closures in golang
- Report on investment analysis and prospect trend prediction of China's MOCVD industry Ⓤ 2022 ~ 2028
猜你喜欢

JDBC and MySQL database

C语言指针面试题——第二弹

Hands on deep learning (38) -- realize RNN from scratch

C language pointer classic interview question - the first bullet

xxl-job惊艳的设计,怎能叫人不爱

2022-2028 research and trend analysis report on the global edible essence industry

2022-2028 global gasket plate heat exchanger industry research and trend analysis report

Hands on deep learning (44) -- seq2seq principle and Implementation

The child container margin top acts on the parent container

How does idea withdraw code from remote push
随机推荐
mmclassification 标注文件生成
Summary of the most comprehensive CTF web question ideas (updating)
Write a jison parser from scratch (1/10):jison, not JSON
Normal vector point cloud rotation
C # use gdi+ to add text with center rotation (arbitrary angle)
直方图均衡化
Are there any principal guaranteed financial products in 2022?
Launpad | 基礎知識
Kotlin:集合使用
什么是 DevSecOps?2022 年的定义、流程、框架和最佳实践
Multilingual Wikipedia website source code development part II
回复评论的sql
ASP. Net to access directory files outside the project website
How do microservices aggregate API documents? This wave of show~
Explanation of for loop in golang
Basic data types in golang
el-table单选并隐藏全选框
About the for range traversal operation in channel in golang
自动化的优点有哪些?
How to batch change file extensions in win10