/*
*copyright (c) 2014, Yantai University School of computer *all rights reserved. * File Name: 16 weeks (OJ 2)
* Wangzhong
* Completion Date: 2014.12.15
* Version Number: v1.0
*
* Problem Description: Whether there is the same element in a array of a data and b array of N2 data
* Input Description: Enter two sets of numbers
* Program output: Whether the output has the same element
#include <iostream>using namespace Std;bool existthesame (int *a,int n1,int *b,int n2); N1 is the same element in the a array of data and in the B array of N2 data, int main () { int a[50]; int b[50]; int I, N1, N2; Read-in data cin>>n1; for (i=0;i<n1;i++) cin>>a[i]; cout<<endl; cin>>n2; for (i=0;i<n2;i++) cin>>a[i]; BOOL Flag=existthesame (A,N1,B,N2); if (flag==true) cout<< "yes\n"; else cout<< "no\n"; return 0;} BOOL Existthesame (int *a,int n1,int *b,int n2) { bool k=false; for (int i=0;i<n1;i++) for (int j=0;j<n2;j++) { if (a+i==b+j) k=true; break; } break; return k;}
16 weeks (OJ 2)