Guest User

Untitled

a guest
Feb 21st, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using std::cin;
  4. using std::cout;
  5. using std::endl;
  6.  
  7. int main()
  8. {
  9. int SIZE = 4;
  10. int tenTo100[SIZE];
  11. int temp = 0;
  12. int counter = 0;
  13. int numToDisplay = SIZE;
  14.  
  15. for(int x = 0;x <= SIZE;++x)
  16. {
  17. cin >> temp;
  18. while(!(temp >= 10 && temp <= 100)) //checks the range of the temp number.
  19. {
  20. cout << "enter a new number between 10 and 100: ";
  21. cin >> temp;
  22. }
  23.  
  24. if(x == 0)
  25. {
  26. tenTo100[counter] = temp;
  27. ++counter;
  28. }
  29. else if(x > 0)
  30. {
  31. bool isDup = false;
  32. for(int y = counter-1; y >= 0; --y)
  33. {
  34. if(temp == tenTo100[y])
  35. {
  36. isDup = true;
  37.  
  38. }
  39.  
  40. }
  41.  
  42. if(isDup == false)
  43. {
  44. tenTo100[counter] = temp;
  45. ++counter;
  46. }
  47.  
  48. }
  49.  
  50. }//end of the for loop
  51.  
  52.  
  53. cout << endl;
  54.  
  55. for(int y = 0; y <= counter-1;++y)
  56. {
  57. cout << tenTo100[y];
  58. cout << endl;
  59. }
  60.  
  61. return 0;
  62. }
Add Comment
Please, Sign In to add comment