daily pastebin goal
49%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <fstream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5. ofstream out("out.out");
  6.  
  7. void citire( int v[], int &nr, char s[30]){
  8.  
  9.  ifstream f(s);
  10.  int i;
  11.  f>>nr;
  12.  for(int i=0;i<=nr-1;i++)
  13.     f>>v[i];
  14.  f.close();
  15.  
  16.     }
  17.  
  18.  
  19.     int afisare(int v[],int nr){
  20.      for(int i=0;i<nr;i++)
  21.         out<<v[i]<<" ";
  22.         out<<endl;
  23.     }
  24.     void sortare(int v[], int nr){
  25.     sort(v,v+nr);}
  26.    void Interclasare(int a[], int b[], int c[],int &k, int m ,int n){
  27.   int i=0;
  28.   int  j=0;
  29.    k=0;
  30.    while(i<=m-1 && j<=n-1)
  31.     if(a[i]<b[j])
  32.     {
  33.         c[k]=a[i];
  34.         i++;
  35.         k++;
  36.     }
  37.     else
  38.     c[k++]=b[j++];
  39.     while(i<=m-1)
  40.         c[k++]=a[i++];
  41.     while(j<=n-1)
  42.         c[k++]=b[j++];
  43.  
  44.    }
  45.  
  46.  
  47. int main()
  48. {
  49.     int a[1001],b[1001],c[2002],m,n,k;
  50.     citire(a,m,"1.in");
  51.     citire(b,n,"2.in");
  52.     afisare(a,m);
  53.     afisare(b,n);
  54.     sortare(a,m);
  55.     sortare(b,n);
  56.     afisare(a,m);
  57.     afisare(b,n);
  58.     Interclasare(a,b,c,k,m,n);
  59.     afisare(c,k);
  60.  
  61.   return 0;
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top