Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //thanks God For Every Thing!
- //contest link:
- //#include<bits/stdc++.h>
- #include<iostream>
- #include<string>
- #include<algorithm>
- #include<cstdio>
- #define pi acose(-1)
- #define flush cin.ignore(numeric_limits<streamsize>::max(),'\n');
- #define wow ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
- #define NL printf("\n")
- using namespace std;
- typedef long long int ll;
- typedef double dl;
- // ---------------------- slove---------------------------//
- int finding(int arr[], int siz, int se);
- int main()
- {
- int n1, n2, i, j, x;
- int s1[100], s2[100], s3[100];
- int a=0, b=0;
- cout<<"Size of Array 1:"; //taking arr1 size input
- cin>>n1;
- flush
- for( i=0; i<n1; i++)
- {
- cin>>s1[i];//taking arr1 input
- }
- cout<<"Size of Array 2:"; //taking arr2 size input
- cin>>n2;
- flush
- for( i=0; i<n2; i++)
- {
- cin>>s2[i];//taking arr2 input
- }
- int se, ans;
- cout<<"enter data to search : "; //taking finding number input
- cin>>se;
- //starting mearge two array
- for(i=0; i<n1; i++)
- {
- s3[i]=s1[i];
- }
- int to;
- to = n1+n2;
- for(i=0, x = n1; x<to, i<n2; i++, x++)
- {
- s3[x]=s2[i];
- }
- //starting sorting
- sort(s3, s3+to);
- cout<<"The sorted array is "<<endl;
- for(i=to-1; i>=0; i--)
- {
- cout<<s3[i]<<" ";
- }
- NL;
- NL;
- ans = finding(s3, to, se); //finding function call;
- cout<<se<<" is found "<<ans<<" times in array"<<endl;
- return 0;
- }
- int finding(int arr[], int siz, int se)
- {
- int cnt=0;
- for(int i=0; i<siz; i++){
- if(se == arr[i]){
- cnt++;
- }
- }
- return cnt;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement