Когда я ввожу «1» (без кавычек) в качестве ввода, я перехожу в меню ошибок (неверный ввод).
Перефразировать:
Когда я запускаю программу, в начальном меню приглашения формы или в меню «неверный ввод», я не могу перейти к выбору «1», если ввожу его как ввод.
Кто-нибудь знает, что здесь происходит?
#include <iostream>
#include <string>
#include <limits>
using std::cout;
using std::cin;
using std::string;
using std::endl;
int main()
{
string username;
cout<<"Hello.\nMy name is Pythagoras.\nI will be helping you build shapes today.\n\nWhat is your name?\n"<<endl;
cin>>username;
int shapeselect;
cout<<"Hello, "<<username<<".\nWhat shape would you like to build today?\n1)Rectangle/Square\n2)Triangle\n3)Random!\n(Please select a number.)\n"<<endl;
cin>>shapeselect;
while (shapeselect!=1||shapeselect!=2||shapeselect!=3)
{
cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
cout<<"Sorry, "<<username<<", your entry was invalid. Please select a valid number.\n";
cout<<"What shape would you like to build today, "<<username<<"?\n1)Rectangle/Square!\n2)Triangle!\n3)Random!"<<endl;
cin>>shapeselect;
}
if (shapeselect==1)
{
int width;
cout<<"\nPlease enter the desired WIDTH of the rectangle, between 4 and 10.\n(Please select a number.)\n";
cin>>width;
cout<<"\nYou have selected a width of "<<width<<"."<<endl;
int length;
cout<<"\nPlease enter the desired LENGTH of the rectangle, between 4 and 10.\n(Please select a number.)\n";
cin>>length;
cout<<"\nYou have selected a length of "<<length<<"."<<endl;
if (width==length)
{
cout<<"Please note that you have selected a width of "<<width<<" and a length of "<<width<<".\nNote that this shape will be a square.\n"<<endl;
}
}
return 0;
}