this is the code
#include <stdio.h>
int main (void)
{
int main[]={3,4,3,1,1,8,6,10};
int second[]={1,2,7,8};
int lenm=sizeof(main)/sizeof(int);//which mean the length of (main)array
int lens= sizeof(second)/sizeof(int);//which mean the length of (second)array
int help=0;
help=lenm;
for(int i=0;i<lenm;i++)
{
for(int q=0;q<lens;q++)
{
if(main[i]==second[q])
{
for(int k=i;k<lenm;k++)
{
main[i]=main[i+1];
}
lenm--;
}
}
}
printf("array after delete is : ");
for (int i=0;i<lenm;i++)
{
printf("%i,",main[i]);
}
printf("\n");
return 0;
}
________________________________________________________________________________there is no compiler errors
the expected result is (array after delete is :: 3,4,3,6,10,)
and the result now is (array after delete is :: 3,4,3,1,8,)
I asked this question befor this and the users said that I must make some meaningful names so I edit the code and asked again
Aucun commentaire:
Enregistrer un commentaire