Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  lru
Language: C/C++
Code:
#include<stdio.h>
#include<math.h>
main()
{
     int n,size,ref[20],dummy[20],a[20],i,l,j,e,f;
        int trap,jkl,m,tp,c;
     printf("enter array");
     scanf("d",&n);
     printf("enter elements");
     for(i=0;i<n;i++)
          scanf("%d",&ref[i]);
     for(i=0;i<3;i++)
          a[i]=ref[i];
     c=3;
     for(i=0;i<size;i++)
     {
  if(ref[i]==a[i] || ref[i]==a[i+1]||ref[i]==a[i+2])
     {}
     else
     {
          trap=0;m=0;
          for(j=i-1;j>=0;j--)
          {
               if(trap!=3)
               {
                    dummy[m]=ref[j];
                    m++;
               }
               for(l=0;l<m-1;l++)
               {
                    if[ref[j]==dummy[l];
                    {}
                    else
                         trap++;
               }
          }
     }
     for(e=0;e<3;e++)
     {
          tp=0;
          for(f=0;f<m;f++)
          {
               if(a[e]==dummy[f])
                    tp++;
          }
          if(tp==0)
          {
               a[e]=ref[i];
               c++;
          }
     }
     }
     printf("%d",c);
  }

          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
Comments: