Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8. int layers,dimension;
  9. char input;
  10.  
  11. //Programmikoodis pole siin süntaktilisi vigasi, ta käivitub ilusti aga ei tööta päris nii nagu vaja
  12. //1. Parandage kolmnurga ja ruudu ülesanne, et nad töötaksid
  13. //2. Lisa kas tagurpidi kolmnurga või ristküliku joonestamine
  14. //3. Pärast nende lõpetamist, näita ette. Siis kui sobib, kirjutad ise vead sisse teistele parandamiseks.
  15. //4. Anna enda vigane programmitükk teisele parandada.
  16. //5. Küsi teistelt vigane programmitükk ja paranda.
  17.  
  18.  
  19. while(true){
  20.  
  21. cout << "Insert what you wish to do: " << endl;
  22. cout << "t -> print a triangle n layers tall" << endl;
  23. cout << "s -> print a square with the size of n" << endl;
  24. cout << "k -> print a triangle n layers tall upside down" << endl;
  25. cin >> input;
  26.  
  27. if(input == 'q') {
  28. cout << "Goodbye!";
  29. break;
  30. }
  31.  
  32.  
  33. //print a triangle with the height of layers and bottom width of layers
  34. if(input == 't') {
  35. cout << "Insert the number of layers you desire: ";
  36. cin >> layers;
  37.  
  38. for(int level = 1; level<=layers; level++) {
  39.  
  40. for(int width = 1; width<=level; width++) {
  41. cout << "* ";
  42. }
  43. cout << endl;
  44.  
  45. }
  46.  
  47. }
  48.  
  49. //Print a square with user inserted dimension (3x3, 4x4, so forth)
  50. if(input == 's') {
  51. cout << "Insert the square dimension: ";
  52. cin >> dimension;
  53.  
  54. for(int level = 1; level<=dimension; level++) {
  55.  
  56. for(int width = 1; width<=dimension; width++) {
  57. cout << "* ";
  58. }
  59. cout << endl;
  60.  
  61. }
  62. }
  63.  
  64. if(input == 'k') {
  65. cout << "Insert the number of layers you desire: ";
  66. cin >> layers;
  67.  
  68. for(int level = 1; level<=layers; level++) {
  69.  
  70. for(int width = layers; width>=level; width--) {
  71. cout << "* ";
  72. }
  73. cout << endl;
  74.  
  75. }
  76.  
  77. }
  78.  
  79.  
  80. }
  81.  
  82.  
  83. return 0;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement