Problem Description
Small W gets two files. There are n integers in each file. Small W wants to know whether these two files are same. So he invites you to write a program to check whether these two files are same. Small W thinks that two files are same when they have the same integer set.
For example file A contains (5,3,7,7),and file B contains (7,5,3,3). They have the same integer set (3,5,7), so they are same.
Another sample file C contains(2,5,2,5), and file D contains (2,5,2,3).
The integer set of C is (2,5),but the integer set of D is (2,3,5),so they are not same.
Now you are expected to write a program to compare two files with size of n.
 
Input
Multi test cases (about 100). Each case contain three lines. The first line contains one integer n represents the size of file. The second line contains n integers a1,a2,a3,…,an - represents the content of the first file. The third line contains n integers b1,b2,b3,…,bn - represents the content of the second file.
Process to the end of file.
1≤n≤100
1≤ai,bi≤1000000000
 
Output
For each case, output "YES" (without quote) if these two files are same, otherwise output "NO" (without quote).
 
Sample Input
3
1 1 2
1 2 2
4
5 3 7 7
7 5 3 3
4
2 5 2 3
2 5 2 5
3
1 2 3
1 2 4
 
Sample Output
YES
YES
NO
NO
 
 #include <stdio.h> 

 int main(){
int n;
int number;
int i;
int j;
int array1[];
int array2[];
int length1;
int length2;
int temp; while(scanf("%d",&n)!=EOF){
length1=;
for(i=;i<n;i++){
scanf("%d",&number); if(i==){
array1[]=number;
length1++;
continue;
} for(j=;j<length1;j++){
if(number==array1[j])
break;
} if(j==length1){
array1[length1]=number;
length1++;
}
} for(i=;i<length1-;i++){
for(j=i+;j<length1;j++){
if(array1[i]>array1[j]){
temp=array1[i];
array1[i]=array1[j];
array1[j]=temp;
}
}
} /*for(i=0;i<length1;i++)
printf("%d ",array1[i]);
printf("\n");*/ length2=;
for(i=;i<n;i++){
scanf("%d",&number); if(i==){
array2[]=number;
length2++;
continue;
} for(j=;j<length2;j++){
if(number==array2[j])
break;
} if(j==length2){
array2[length2]=number;
length2++;
}
} for(i=;i<length2-;i++){
for(j=i+;j<length2;j++){
if(array2[i]>array2[j]){
temp=array2[i];
array2[i]=array2[j];
array2[j]=temp;
}
}
} /*for(i=0;i<length2;i++)
printf("%d ",array2[i]);
printf("\n");*/ if(length1!=length2){
printf("NO\n");
continue;
} for(i=;i<length1;i++){
if(array1[i]!=array2[i]){
printf("NO\n");
break;
}
} if(i==length1)
printf("YES\n"); } return ;
}

最新文章

  1. 线程安全及Python中的GIL
  2. pig相关
  3. getServletPath getRequestURI getRequestURL区别
  4. 重新想象 Windows 8.1 Store Apps (91) - 后台任务的新特性: 下载和上传的新特性, 程序启动前预下载网络资源, 后台任务的其它新特性
  5. Linux-Ubuntu 启用root账户
  6. Jasper_crosstab_group _Error incrementing crosstab dataset
  7. Android UI方面的学习记录
  8. IIS下访问网络驱动器(网络位置)
  9. 8、手把手教你Extjs5(八)自定义菜单2
  10. 统一代码风格工具——editorConfig
  11. Eclipse搭建Maven项目之准备工作
  12. sql2008r2,以前好好可以用的,但装了vs2017后,连接不上了,服务也停了,结果手动也 启动不了, 无法加载或初始化请求的服务提供程
  13. 强化学习(九)Deep Q-Learning进阶之Nature DQN
  14. MySQL字符集 utf8 和 utf8mb4 区别及排序规则 general_ci 和 unicode_ci 和 bin 的区别
  15. ClassLoader家族
  16. 创业维艰--&gt;&gt;书摘+乱七八糟
  17. AARRR海盗模型简介
  18. 解决 Mac 的 Terminal 中,Java 乱码的问题
  19. 20145311王亦徐 《网络对抗技术》 MSF基础应用
  20. Markdon 作图语法 CSDN

热门文章

  1. c++ memset函数
  2. [POI2013]POL-Polarization
  3. Android 性能优化(11)网络优化( 7)Optimizing for Doze and App Standby
  4. Matlab vs Python 作图
  5. 64位linux安装wine等软件
  6. 聊聊MyBatis缓存机制
  7. Java 创建Excel并逐行写入数据
  8. [ Nowcoder Contest 167 #D ] 重蹈覆辙
  9. Position属性四个值:static、fixed、absolute和relative的区别
  10. 前端--2、CSS基础