Cod sursa(job #473290)

Utilizator bogdan32xMariesan Bogdan Emil bogdan32x Data 28 iulie 2010 16:14:22
Problema Cel mai lung subsir comun Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.77 kb
#include<fstream.h>

long n,m,a[1025],b[1025],c[1025];

int main()
{long i,j;
 ifstream f("cmlsc.in");
 ofstream g("cmlsc.out");
 
 f>>n;
 f>>m;
 
 for(i=0;i<n;i++)
                 f>>a[i];
 for(j=0;j<m;j++)
                 f>>b[j];
 
                long contor=0;
       
                  
                  for(j=0;j<m;j++)
                  {
                                  for(i=0;i<n;i++)
                                             if(a[i]==b[j]) {c[++contor]=a[i]; break; }
                                  }
                                    
                  
            
       
       g<<contor<<"\n";
       for(i=1;i<=contor;i++)
                            g<<c[i]<<" ";
       
 f.close();
 g.close();
 return 0;    
    
}