Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. /**
  2. *
  3. * Solution to homework assignment 1
  4. * Introduction to programming course
  5. * Faculty of Mathematics and Informatics of Sofia University
  6. * Winter semester 2019/2020
  7. *
  8. * @author <Velislava Petkova>
  9. * @idnumber <62428>
  10. * @task <4>
  11. * @compiler <VC>
  12. *
  13. */
  14.  
  15. #include <iostream>
  16. #include <cmath>
  17. #include <stdlib.h>
  18. using namespace std;
  19. int main()
  20. {
  21. system("COLOR 3");
  22. int myNumber = 0;
  23. cout << "Input a number to start the countdown: ";
  24. cin >> myNumber;
  25. system("cls"); //Clears the screen after our input
  26. if (!cin)
  27. {
  28. cout << "It is not an accurate number " << endl; //Checks if the input is correct
  29. return 1;
  30. }
  31. else if (myNumber<1 || myNumber > pow(2, 16) - 1)
  32. {
  33. cout << "It is not an accurate number " << endl;
  34. return 1;
  35. }
  36. else
  37. {
  38. while (myNumber >= 0)
  39. {
  40. cout << myNumber; //Displays our number
  41. long long help = 0;
  42. do
  43. {
  44. help += 2; //A loop to help slowing down the operation
  45. help -= 1;
  46.  
  47. } while (help <= 300000000);
  48. myNumber--; //We reduce the number by 1, we clear the screen and display the new number
  49. system("cls");
  50.  
  51. }
  52.  
  53. }
  54.  
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement