قُلْ إِنَّ صَلَاتِي وَنُسُكِي وَمَحْيَايَ وَمَمَاتِي لِلَّـهِ رَبِّ الْعَالَمِينَ - الأنعام: ١٦٢

Monday, September 28, 2009

Detecting the "Enter" key

السلام عليكم و رحمة الله و بركاته

This is a short post.
almost a year ago, I tried to solve a problem on the UVa and i got it "Time limit exceeded". I knew before submitting that it won't be accepted, as i didn't know how to detect the "Enter" key press and it was needed as a stop condition for the first loop :D

anyway, here we go
if you are trying to use "cin" then you'll not be able to detect the new line.
when debugging, u may enter 10 new lines & then a value...i mean it will wait for the value and won't consider the new lines!

you may go to a lower level
if(cin.get() == '\n')
but that's when u are expecting the enter to be pressed
as it reads 1 char only

or u can use "cin.getline()"
and then check for the string's length
if == 0 then "Enter" is pressed
That's useful when u r expecting a mix of strings & enters


sources:
ACMaa Magdi (thanks :))

Thursday, September 24, 2009

Let's Share, shall we?

السلام عليكم و رحمة الله و بركاته

Do u remember having some milestone in a code & finding the solution somewhere online??
happens a lot, right?

i do remember our algorithms project...when my friends & me searched for the algorithms online
and sometimes we used to get the source code to be able to understand something
i remember LOTS of assignments and searching for codes to do a specific task
i remember searching for a function and not understanding it except when i see it in use
i guess we all had this very same experience through our past years in college

for me, it has been from the very first time I started writing code that I considered the Internet as my primary gate. It has always been helpful.
So i guess now it's time to pay back.

Many people have this urge of helping others. I felt this spirit in FCIS.
Students giving sessions, posting informative topics in their blogs, helping each others in anything & everything!

I owe Roaa for motivating me to do the prolog project. I used to hate it, really, and i just didn't know what could be done with this silly language.
I downloaded her documentation & saw the program snapshots. Thinking that she was just as old as me, and nearly with the same experience gave me the required confidence and the will to do something good.
I also remember in our algorithms project when we didn't know how to read the image to do the processing we needed, we almost did it because of her topic here
last but not least, open sourcing their image package project :). Well, i personally think that it was a great idea, and I guess it will motivate people to share more :)

So now that I have the urge to help others. I decided putting every useful thing I write online for people to get use of.
I know for a fact that I'm not very good in writing code. Maybe I'm not the most organized nor the most optimized. But at least I find a way to get the job done, and maybe it will help someone.
It's an open invitation for you to help others :)

Good links:

feel free to add more resources :)

SPREAD KNOWLEDGE: الحكيــــــــــــــــــــــــــــــــــــم

السلام عليكم و رحمة الله و بركاته

just read a post in my little sister's blog, and thought of sharing it

SPREAD KNOWLEDGE: الحكيــــــــــــــــــــــــــــــــــــم

It reminded me of the quote:
"Two men look out the same prison bars; one sees mud and the other stars."

Most of the time ppl have different opinions in the same thing. You may ask yourself how come
someone saw something in some way different than u? and u may think it is totally weird and everything, but it is not weird at all!
we all have different backgrounds. We don't share the same type of thinking nor the external effects.
In other words we don't all wear the same glasses!

So what can we do about this?
It's really simple...
-listen to other people
-put yourself in their shoes
-accept that we are all different
-try to appreciate a little

and remember to make sure that you understood what the other person is telling you in the way he/she means it.
always ask for feedback :)


Sunday, September 20, 2009

تكبيرات العيد

السلام عليكم و رحمة الله و بركاته
very nice takbeerat :)
enjooy :)




Happy Eid