Finding the same values in the mass



  • The challenge is to find the same meaning in the mass. What's wrong with the code?

    void main(void)
    {
        int a[5]={1,5,3,4,5},i=0,k;
    
    for(k=0;k<=4;k++)
    {
        do
        {
            if(a[k]==a[i]){
                printf("%i",a[i]);
            }
            i++;
        }
        while((i-4)==0);
    }
    _getch();
    

    }



  • void main()
    { int a[5]={1,2,3,4,5};
    int i=0;k=0;
    
    for (i=0; i<5; i++) {
    
          for(k=5;k>i;k-1){
    
            if(a[i]==a[k]){Напечатать сообщение или убить всех человеков;}
         }
      }
    }
    

    The point is that the programme will compare one element to all in the mass, then the second element to all, etc.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2