Мне дали псевдокод для перевода на C++:
Set a Boolean variable “first” to true.
While another value has been read successfully
If first is true
Set the minimum to the value.
Set first to false.
Else if the value is less than the minimum
Set the minimum to the value.
Print the minimum
И вот мои коды:
bool first = true;
bool read_value = true;
int value = 0;
int minimum = 0;
cout << "Enter an integer : " ;
cin >> value;
while(cin.hasNextInt()) // error here
{
cout << "Enter another integer : " ;
cin >> minimum;
if( first == true){
minimum = value;
first = false;
}else if ( value < minimum){
minimum = value;
}
}
cout << minimum;
system("PAUSE");
return 0;
Там есть ошибка в hasNextInt. И я действительно не знаю, чего хочет псевдокод. Кто-нибудь может мне объяснить?
Заранее спасибо.