fork download
  1. //@Author Damien Bell
  2. #include <iostream>
  3. #include <cmath>
  4. using namespace std;
  5. int main(){
  6. int choice=0, i, j;
  7.  
  8. cout << "How many digits do you want to use: ";
  9. cin >> choice;
  10.  
  11. //One set of loops to count up to 5
  12.  
  13. for(i=1; i<=choice; i++){//outer loop
  14.  
  15. for(j=1; j<=i; j++){//inner loop
  16.  
  17. cout << j; //Cout present counter for J
  18.  
  19. }//end inner loop
  20.  
  21. cout << endl; // Line break
  22.  
  23. }//end outer loop
  24.  
  25.  
  26.  
  27. //Use another set of nested loops to count down from choice
  28.  
  29. for (i=choice; i >0; i--){//Outer loop
  30.  
  31. for(j=1; j<=i; j++){//Inner loop
  32.  
  33. cout << j ;//output current j
  34.  
  35. }//end inner loop
  36.  
  37. cout <<endl;//line break
  38.  
  39. }//end outer loop
  40.  
  41.  
  42.  
  43.  
  44. //one set of loops to count down from 5
  45.  
  46. return 0;
  47. }
  48.  
  49. /*
  50.  
  51.  
  52.  * 1
  53.  * 12
  54.  * 123
  55.  * 1234
  56.  * 12345
  57.  * 1234
  58.  * 123
  59.  * 12
  60.  * 1
  61.  *
  62.  
  63.  */
Success #stdin #stdout 0s 2728KB
stdin
9
stdout
How many digits do you want to use: 1
12
123
1234
12345
123456
1234567
12345678
123456789
123456789
12345678
1234567
123456
12345
1234
123
12
1