Quick actions

cmd+k|ctrl+k

Navigation

Languages

lab6-194

Snippet info

Language

Cpp

Visibility

public

Author

matho.camara

Created

2018-11-28T10:25:09Z

Updated

2018-12-12T09:34:00Z

#include <iostream>
using namespace std;

int main() {
    srand((unsigned) time(NULL));
    
    //random array size
    int p=rand()%10,q=rand()%10,r=rand()%10;
    int find[12];
    int counter=0;
    
    //dynamic array
    int *x=new int[p];
    int *y=new int[q];
    int *z=new int[r];
    //filling the tables
    for(int i=0;i<p;i++)
    {
        x[i]=rand()%20;
    }

    for(int i=0;i<q;i++)
    {
         y[i]=rand()%15;
    }

    for(int i=0;i<r;i++)
    {
         z[i]=rand()%25;
    }
    
    //showing the tables content
    cout<<"Array content :"<<endl;
    cout<<"Array 1 size:"<<p<<endl;
    for(int i=0;i<p;i++)
    {
         cout<<x[i]<<endl;
    }
    cout<<endl;
     cout<<"Array 2 size:"<<q<<endl;
    for(int i=0;i<q;i++)
    {
         cout<<y[i]<<endl;
    }
    cout<<endl;
     cout<<"Array 3 size:"<<r<<endl;
    for(int i=0;i<r;i++)
    {
         cout<<z[i]<<endl;
    }
    
    //searching for a number with p+q+r form
    int number;
    for(int i=0;i<p;i++)
    {
     for (int j=0;j<q;j++)
     {
         for(int k=0;k<r;k++)
         {
            //if((x[i]==p+q+r) && (y[j]==p+q+r) && (z[k]==p+q+r))
            if(x[i] == y[j] && y[j] == z[k])
            {
                number = z[k];
                break;
             
            }
         }
      }
    }
    
    
    cout<<"The founded numbers are: "<<endl;
    //for(int i=0;i<counter;i++)
    //cout<<find[i]<<endl;
    
    cout<<number<<endl;
    
    delete x;
    delete y;
    delete z;
    return 0;
}
INFO