Guest User

Untitled

a guest
Jan 21st, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     char recommencer = 'o';
  8.  
  9.     do
  10.     {
  11.         int nb = 0, suite = 0;
  12.         const int MIN = 1, MAX = 50;
  13.  
  14.         cout << endl << "Saisir un entier compris entre " << MIN << " et " << MAX << " : ";
  15.         cin >> nb;
  16.  
  17.         while (nb < 1 || nb > 50)
  18.         {
  19.             cout << nb << " n'est pas un nombre valable. Recommencer : ";
  20.             cin >> nb;
  21.         }
  22.  
  23.         for (int i = 1 ; i <= nb ; i++)
  24.         {
  25.             suite = (suite - 1) + i;
  26.             cout << suite << " ";
  27.         }
  28.  
  29.         cout << endl << endl << "Voulez-vous recommencer ? (o pour oui, n pour non)" << endl;
  30.         cin >> recommencer;
  31.     }
  32.     while(recommencer != 'n');
  33.  
  34.     return 0;
  35. }
Add Comment
Please, Sign In to add comment