16 weeks (OJ 2)

Source: Internet
Author: User

*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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.