Warp wrote:
> Orchid XP v8 <voi### [at] devnull> wrote:
>> std::string txt;
>> std::cin >> txt;
>
>> std::istringstream iss(txt);
>> int number;
>> iss >> number;
>
> I think you misunderstood the reason to use stringstreams.
Er, yeah, good point...
>> if (number < target) {std::cout << "Too low." << std::endl; continue;}
>> if (number > target) {std::cout << "Too high." << std::endl; continue;}
>> break;
>
> Wouldn't it be simpler to do it like:
>
> if(number == target) break;
> if(number < target) std::cout << "Too low.\n";
> else std::cout << "Too high.\n";
Mmm, I guess that would also work...
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|