Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int layers,dimension;
- char input;
- //Programmikoodis pole siin süntaktilisi vigasi, ta käivitub ilusti aga ei tööta päris nii nagu vaja
- //1. Parandage kolmnurga ja ruudu ülesanne, et nad töötaksid
- //2. Lisa kas tagurpidi kolmnurga või ristküliku joonestamine
- //3. Pärast nende lõpetamist, näita ette. Siis kui sobib, kirjutad ise vead sisse teistele parandamiseks.
- //4. Anna enda vigane programmitükk teisele parandada.
- //5. Küsi teistelt vigane programmitükk ja paranda.
- while(true){
- cout << "Insert what you wish to do: " << endl;
- cout << "t -> print a triangle n layers tall" << endl;
- cout << "s -> print a square with the size of n" << endl;
- cout << "k -> print a triangle n layers tall upside down" << endl;
- cin >> input;
- if(input == 'q') {
- cout << "Goodbye!";
- break;
- }
- //print a triangle with the height of layers and bottom width of layers
- if(input == 't') {
- cout << "Insert the number of layers you desire: ";
- cin >> layers;
- for(int level = 1; level<=layers; level++) {
- for(int width = 1; width<=level; width++) {
- cout << "* ";
- }
- cout << endl;
- }
- }
- //Print a square with user inserted dimension (3x3, 4x4, so forth)
- if(input == 's') {
- cout << "Insert the square dimension: ";
- cin >> dimension;
- for(int level = 1; level<=dimension; level++) {
- for(int width = 1; width<=dimension; width++) {
- cout << "* ";
- }
- cout << endl;
- }
- }
- if(input == 'k') {
- cout << "Insert the number of layers you desire: ";
- cin >> layers;
- for(int level = 1; level<=layers; level++) {
- for(int width = layers; width>=level; width--) {
- cout << "* ";
- }
- cout << endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement