fork download
  1. //Dione Torrevillas CS1A Chapter 5, P. 298, #23
  2. //
  3. /**********************************************************************
  4.  *
  5.  * PATTERN DISPLAYS
  6.  *
  7.  * This program uses loops to display two patterns made from
  8.  * plus signs. Pattern A increases from one plus sign to ten.
  9.  * Pattern B decreases from ten plus signs back to one.
  10.  *
  11.  * INPUT
  12.  * None
  13.  *
  14.  * OUTPUT
  15.  * Pattern A : Increasing rows of plus signs
  16.  * Pattern B : Decreasing rows of plus signs
  17.  *
  18.  **********************************************************************/
  19.  
  20. #include <iostream>
  21. using namespace std;
  22.  
  23. int main()
  24. {
  25. int row; //CALC - Controls the number of rows
  26. int column; //CALC - Controls the number of plus signs
  27.  
  28. //
  29. // Display Pattern A
  30. //
  31. cout << "Pattern A" << endl;
  32.  
  33. for (row = 1; row <= 10; row++)
  34. {
  35. for (column = 1; column <= row; column++)
  36. {
  37. cout << "+";
  38. }
  39.  
  40. cout << endl;
  41. }
  42.  
  43. cout << endl;
  44.  
  45. //
  46. // Display Pattern B
  47. //
  48. cout << "Pattern B" << endl;
  49.  
  50. for (row = 10; row >= 1; row--)
  51. {
  52. for (column = 1; column <= row; column++)
  53. {
  54. cout << "+";
  55. }
  56.  
  57. cout << endl;
  58. }
  59.  
  60. return 0;
  61. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Pattern A
+
++
+++
++++
+++++
++++++
+++++++
++++++++
+++++++++
++++++++++

Pattern B
++++++++++
+++++++++
++++++++
+++++++
++++++
+++++
++++
+++
++
+