Posts

Showing posts from August, 2021

Legend of Narcissism

Image
 Legend of Narcissism Long ago, there was a nymph named Echo, who was a favored servant of Artemis, the Greek goddess of the hunt. Echo loved to talk to anyone and everyone, and often Zeus would use her to distract his wife Hera so he could sneak down from Mt. Olympus and entertain himself with the women of Earth. Eventually, Hera realized what was happening, and in her anger, she cursed Echo so that the nymph could no longer speak any words of her own. Morose at her loss, Echo wandered the lands, only able to repeat what others had said. One day on her travels, she encountered a young man who was very beautiful to behold. She longed to tell him how she felt, but unless he spoke to her first, she could only follow him in silence. Eventually, the man heard the sound of her footsteps, and he called out, 'Who's there?' Echo repeated his words, and again he tried, 'Why do you run from me?', but again she could only repeat what he had said. One more time he spoke, 'L...

Take input till enter is pressed in C++.

 I am assuming that you want to read distinct integer values from a line or a test case until enter is pressed. For example, you need to take space separated integers as input until there is a new line.   First of all, to take input in C++ what we use is "cin". what "cin" does is that it only takes input until there is a space or new line. It do not reads space, so we can't check if the input is '\n' using only "cin", because it completely ignores this space character.  So, to make our program read this space we need use a more lower version of function to take input. For this we have ".get()", ".getLine()", ".getChar()". We can use .get() to take any specific number of characters as input or .getLine() to take whole line as input untill enter key is pressed. But here is the thing that is going to help us, And that is .getChar(), which can read only a single character but this single character can also be  a space ...