Witam,
Mam do napisania program na zadanie domowe i wszystko bangla tylko, że gdy wybieram opcje w menu rysowania prostokątów nie mogę nic dalej zrobić ponieważ program wraca do menu. Co zrobiłem źle?
#include <iostream>
#include <stdio.h>
#include <cstdlib>
using namespace std;
int height, width;
int i, j;
int recth[5];
int rectw[5];
char wybor, wybor2;
void drawSquare(int height)
{
for(i=0; i<height; i++)
{
for(j=0; j<width; j++)
{
cout << "*";
}
cout << endl;
}
}
int main()
{
while(true)
{
cout << " WITAJ W PROGRAMIE 'RECTANGLE' " << endl;
cout << "-------------------------------" << endl;
cout << " 1. DODAJ PROSTOKAT " << endl;
cout << " 2. RYSUJ PROSTOKATY " << endl;
cout << " 3. ZNAJDZ NAJMNIEJSZE " << endl;
cout << " 4. WYJDZ " << endl;
cout << endl;
cout << " TWOJ WYBOR: " << endl;
wybor = getchar();
switch(wybor)
{
case '1':
{
cout << " DODAJ PROSTOKAT " << endl;
cout << endl;
cout << " PODAJ WYSOKOSC " << endl;
cin >> recth[i];
cout << " PODAJ SZEROKOSC " << endl;
cin >> rectw[j];
}
system("cls");
break;
case '2':
{
cout << " RYSUJ PROSTOKATY " << endl;
cout << endl;
cout << " TWOJE PROSTOKATY " << endl;
cout << " 1. " << recth[0] << "x" << rectw[0] << endl;
cout << " 2. " << recth[1] << "x" << rectw[1] << endl;
cout << " 3. " << recth[2] << "x" << rectw[2] << endl;
cout << " 4. " << recth[3] << "x" << rectw[3] << endl;
cout << " 5. " << recth[4] << "x" << rectw[4] << endl; }
cout << endl;
cout << " KTORY PROSTOKAT NARYSOWAC? " << endl;
wybor2=getchar();
switch(wybor2)
{
case '1':
{
for(i=0; i<recth[0]; i++)
{
for(j=0; j<recth[0]; j++)
{
cout << "*";
}
cout << endl;
}
}
break;
case '2':
{
for(i=0; i<recth[1]; i++)
{
for(j=0; j<rectw[1]; j++)
{
cout << "*";
}
cout << endl;
}
}
break;
case '3':
{
for(i=0; i<recth[2]; i++)
{
for(j=0; j<recth[2]; j++)
{
cout << "*";
}
cout << endl;
}
}
break;
case '4':
{
for(i=0; i<recth[3]; i++)
{
for(j=0; j<rectw[3]; j++)
{
cout << "*";
}
cout << endl;
}
}
break;
case '5':
{
for(i=0; i<recth[4]; i++)
{
for(j=0; j<rectw[4]; j++)
{
cout << "*";
}
cout << endl;
}
}
break;
}
break;
}
}
system("pause");
return 0;
}