Advertisement
Guest User

Untitled

a guest
Feb 20th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4.  
  5.  
  6. int main ()
  7.  
  8. {
  9.  
  10. setbuf(stdout, NULL);
  11.  
  12. int nums[20] , i , j, k;
  13. int count=0;
  14.  
  15. {
  16.  
  17. printf("Enter integers. (Negative -1 to stop):\n");
  18. for (i=0; i < count; i++)
  19. {
  20.  
  21.  
  22. scanf("%d", &nums[i]);
  23. count = count +1;
  24. if(nums[i] == -1 )
  25.  
  26. break;
  27.  
  28. }
  29. }
  30. printf("The numbers you entered are:\n");
  31. for(i=1;i<count;++i)
  32. {
  33. printf("%d\n", nums[i-1]);
  34. }
  35. printf("\nThe numbers you entered with the duplicate numbers removed:\n ");
  36.  
  37.  
  38. for(i=0;i<count;i++)
  39. {
  40. for(j=i+1;j<count;)
  41. {
  42. if(nums[j]==nums[i])
  43. {
  44. for(k=j;k<count-1;k++){
  45. nums[k]=nums[k+1];
  46. }
  47. count--;
  48.  
  49. }
  50. else
  51. j++;
  52. }
  53. }
  54.  
  55. for(i=0;i<count;i++)
  56. printf("%d\n ",nums[i]);
  57.  
  58.  
  59.  
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement