fork download
  1. //Xinnuo Wang CS1A chapter 5 , P.298, #23
  2. //
  3. /*******************************************************************************
  4. *
  5. * Display Patterns by loops
  6. *-------------------------------------------------------------------------------
  7. * This program uses a loop to display Pattern A, followed by another loop that
  8. * displays Pattern B
  9. *
  10. *-------------------------------------------------------------------------------
  11. * INPUT
  12. * a : The pattern A
  13. * A : The data to dispaly pattern A
  14. * b : The pattern B
  15. * B : The data to dispaly pattern B
  16. * OUTPUT
  17. *
  18. *******************************************************************************/
  19. #include <iostream>
  20. using namespace std;
  21.  
  22. int main()
  23. {
  24. int A,a,B,b;
  25. //
  26. //Pattern A
  27. for (a=1;a<=10;a++)
  28. {
  29. for(A=0; A<a; A++)
  30. {
  31. cout<<"+";
  32. }
  33. cout<<endl;
  34. }
  35. //
  36. //Pattern B
  37. for (b=10;b>=1;b--)
  38. {
  39. for(B=1; B<=b; B++)
  40. {
  41. cout<<"+";
  42. }
  43. cout<<endl;
  44. }
  45.  
  46. return 0;
  47. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
+
++
+++
++++
+++++
++++++
+++++++
++++++++
+++++++++
++++++++++
++++++++++
+++++++++
++++++++
+++++++
++++++
+++++
++++
+++
++
+