Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int n=0;
  7. int hold;
  8. int count0 =0, count1 =0, count2 =0, count3 =0, count4 =0, count5 =0, count6 =0, count7 =0, count8 =0, count9 =0;
  9.  
  10. while(n == 0){
  11. printf("n=");
  12. scanf("%d", &n);
  13. }
  14.  
  15. while(n != 0){
  16. hold = n%10;
  17. n /=10;
  18. switch(hold){
  19. case 0:
  20. count0++;
  21. break;
  22. case 1:
  23. count1++;
  24. break;
  25. case 2:
  26. count2++;
  27. break;
  28. case 3:
  29. count3++;
  30. break;
  31. case 4:
  32. count4++;
  33. break;
  34. case 5:
  35. count5++;
  36. break;
  37. case 6:
  38. count6++;
  39. break;
  40. case 7:
  41. count7++;
  42. break;
  43. case 8:
  44. count8++;
  45. break;
  46. case 9:
  47. count9++;
  48. break;
  49. }
  50. }
  51.  
  52. if(count0 % 2 == 0 && count0 != 0){
  53. printf("0 ");
  54. }
  55. if(count1 % 2 == 0 && count1 != 0){
  56. printf("1 ");
  57. }
  58. if(count2 % 2 == 0 && count2 != 0){
  59. printf("2 ");
  60. }
  61. if(count3 % 2 == 0 && count3 != 0){
  62. printf("3 ");
  63. }
  64. if(count4 % 2 == 0 && count4 != 0){
  65. printf("4 ");
  66. }
  67. if(count5 % 2 == 0 && count5 != 0){
  68. printf("5 ");
  69. }
  70. if(count6 % 2 == 0 && count6 != 0){
  71. printf("6 ");
  72. }
  73. if(count7 % 2 == 0 && count7 != 0){
  74. printf("7 ");
  75. }
  76. if(count8 % 2 == 0 && count8 != 0){
  77. printf("8 ");
  78. }
  79. if(count9 % 2 == 0 && count9 != 0){
  80. printf("9 ");
  81. }
  82.  
  83. return 0;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement