fork download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<limits.h>
  4. int main(int argc, char const *argv[])
  5. {
  6. int *t, n, x, cpt=0, min=INT_MAX ,pos_min=0;
  7. printf("privide the array size");
  8. scanf("%d",&n);
  9. t=(int *) malloc(n*sizeof(int));
  10. for(int i=0; i<n; i++)
  11. scanf("%d",t+i);
  12. for (int i = 0; i < n; ++i)
  13. {
  14. if(min>*(t+i))
  15. {
  16. min=*(t+i);
  17. pos_min=i;
  18. }
  19. }
  20. for (int i = pos_min; i < n-1; ++i)
  21. {
  22. t[i]=t[i+1];
  23. }
  24.  
  25. printf("privide the number to delete from the array");
  26. scanf("%d",&x);
  27. for (int i = 0; i < n; ++i)
  28. {
  29. if(t[i]!=x)
  30. t[cpt++]=t[i];
  31. }
  32. t=realloc(t, sizeof(int)*(cpt-1));
  33. for (int i = 0; i < cpt-1; ++i)
  34. {
  35. printf("%d\t",t[i]);
  36. }
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0.01s 5292KB
stdin
10
1
2
3
1
2
3
1
0
2
3
1
stdout
privide the array sizeprivide the number to delete from the array2	3	2	3	2	3