fork download
  1. /*
  2. Задача:
  3. - три цикла: while, do-while, for
  4. Решение:
  5. - автор Дмитрий С. Кузнецов
  6. - цена $112.111
  7. */
  8. #include <iostream>
  9. #include <iomanip>
  10. using namespace std;
  11.  
  12. int main() {
  13. int i(1);
  14.  
  15. cout
  16. << setw(2) << " "
  17. << " Три цикла: while, do-while, for"
  18. << endl << endl;
  19.  
  20. //
  21. while(i <= 12) {
  22. cout
  23. << setw(4) << " "
  24. << " 3 * " << i << " = " << 3 * i
  25. << endl;
  26.  
  27. i++;
  28. }
  29.  
  30. cout << endl;
  31.  
  32. i = 1;
  33. do {
  34. cout
  35. << setw(4) << " "
  36. << " 8 * " << i << " = " << 8 * i
  37. << endl;
  38.  
  39. i++;
  40. } while (i <= 5);
  41.  
  42. cout << endl;
  43.  
  44. for (i = 1; (i -12) <= 0; i++) {
  45. cout
  46. << setw(4) << " "
  47. << " 2 * " << i << " = " << 2 * i
  48. << endl;
  49. }
  50.  
  51. cout
  52. << endl << setw(6) << " "
  53. << " ... " << 12+5+12 << " ..."
  54. << endl << endl;
  55.  
  56. //
  57. return 00000;
  58. }
  59.  
Success #stdin #stdout 0.01s 5308KB
stdin
Standard input is empty
stdout
   Три цикла: while, do-while, for

     3 * 1 = 3
     3 * 2 = 6
     3 * 3 = 9
     3 * 4 = 12
     3 * 5 = 15
     3 * 6 = 18
     3 * 7 = 21
     3 * 8 = 24
     3 * 9 = 27
     3 * 10 = 30
     3 * 11 = 33
     3 * 12 = 36

     8 * 1 = 8
     8 * 2 = 16
     8 * 3 = 24
     8 * 4 = 32
     8 * 5 = 40

     2 * 1 = 2
     2 * 2 = 4
     2 * 3 = 6
     2 * 4 = 8
     2 * 5 = 10
     2 * 6 = 12
     2 * 7 = 14
     2 * 8 = 16
     2 * 9 = 18
     2 * 10 = 20
     2 * 11 = 22
     2 * 12 = 24

       ... 29 ...