我已经编写了这段代码,但是当它要求用户输入一个新数字来创建一个正方形时,它不会打印这个正方形。任何人都可以解释/帮助我吗?
// ask user to repeat the process again at end of the first promt
while ( num > 1 || num < 20 )
{
ask user to repeat the process again at end of the first promt
while ( num > 1 || num < 20 )
{
// ask user t enter a square
cout << "Please enter size of square between #1-20: \n";
cin >> buf; num = atoi (buf.c_str());
cin.ignore(1000, 10);
// process of printing square
while ( num >= a)
{
b = 1;
while ( num >= b )
{
if ( a == 1 || a == num || b == 1 || b == num )
cout << "*";
else
cout << " ";
b++;
}
cout << endl;
a++;
}