Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. // program.cpp : Defines the entry point for the console application.
  2. //libraries
  3. #include "stdafx.h"
  4. #include <iostream>
  5. #include <string>
  6. #include <cstdlib>
  7. #include <math.h>
  8.  
  9. using namespace std;
  10.  
  11.  
  12. int _tmain(int argc, _TCHAR* argv[])
  13. {
  14. int input1, input2, new1, new2, temp, counter = 0;
  15.  
  16. cout << "Enter the 1st number: ";
  17. cin >> input1;
  18. new1 = input1;
  19.  
  20. cout << "Enter the 2nd number: ";
  21. cin >> input2;
  22. new2 = input2;
  23. cout << endl;
  24.  
  25. cout << input1 << " " << input2 << " ";
  26. do {
  27. counter++;
  28. temp = (new1 + new2) % 10;
  29. cout <<temp << " ";
  30. new1 = new2;
  31. new2 = temp;
  32. } while (!(new1 == input1 && new2 == input2));
  33.  
  34. cout <<endl <<"It took " << counter << " steps to close the necklace." <<endl;
  35.  
  36. system("pause");
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement