/* Copyright (c) 2014, Yantai University School of Computer * All rights reserved. * File name: Test.cpp * Chen Dani * Completion Date: December 11, 2014 * version number: v1.0 * * Problem Description: Whether there is the same number * Input Description: Enter several integer numbers * Program output: Yes or no */ #include <iostream>using namespace std;bool existthesame (int *a,int n1,int *b,int n2); int Main () { int a[50]; int b[50]; int I, N1, N2; cin>>n1; for (i=0; i<n1; i++) cin>>a[i]; cin>>n2; for (i=0; i<n2; i++) cin>>b[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 *p=a, p<a+n1; p++) for (int *q=b; q<b+n2; q++) { if (*p==*q) k=true; } return k;}
Learning experience: Remember to carefully check the small problems, try to avoid mistakes.
Training the cycle, already can write their own code, refueling, this is progress!
16th Week OJ Item two--with the same number