Advertisement
ateyevtm

Untitled

Nov 19th, 2021
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. /*#include <iostream>
  2. using namespace std;
  3. int main(){
  4. setlocale(LC_ALL, "Russian");
  5. int n;
  6. int fact = 1;
  7. cout << "Введите факториал: " ;
  8. cin >> n;
  9. for(int i = 1; i <=n; ++i){
  10. fact *= i;
  11. }
  12. cout << "Factorial = " <<fact ;
  13. return 0;
  14. }*/
  15. #include <iostream>
  16.  
  17. using namespace std;
  18.  
  19. int main() {
  20.  
  21. double A;
  22.  
  23. int S{0}, counter{1};
  24.  
  25. cout << "Enter number: ";
  26.  
  27. cin >> A;
  28.  
  29.  
  30. do
  31.  
  32. {
  33.  
  34. S += counter;
  35.  
  36. counter++;
  37.  
  38. } while (A > S);
  39.  
  40. cout << S << '\n';
  41.  
  42. counter = 1;
  43.  
  44. S = 0;
  45.  
  46.  
  47.  
  48.  
  49. while (A > S)
  50.  
  51. {
  52.  
  53. S += counter;
  54.  
  55. counter++;
  56.  
  57. }
  58.  
  59. cout << S << '\n';
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement