jeudi 18 février 2016

compare and delete the same value but the result is the same array that i entered at first

#include <stdio.h>

int main (void)
{
    int r[]={3,4,3,1,1,8,6,10};
    int s[]={1,2,7,8};
    int help[100];
    int lr=sizeof(r)/sizeof(int);
    int ls= sizeof(s)/sizeof(int);
    int ctr=0;


    for(int i=0;i<lr;i++)
    {

        for(int q=0;q<ls;q++)
        {   
            if(r[i]==s[q])
            {
                help[ctr]=r[i];
                ctr++;
            }

        }
    }
    //show(r,lr);
    printf("array after delete is : ");
    for (int i=0;i<lr;i++)
    {
        printf("%i,",r[i]);
    }
    printf("\n");
    return 0;
}


I don't know what is the problem I think that I wrote the code wright but the result is the same of the first array could you help me

please don't say something bad I am a new student

Aucun commentaire:

Enregistrer un commentaire