< Browse > Home

C++ Recursion – Summation

November 13th, 2009 | 2 Comments | Posted in C++ by Diego | - [Full Entry]

Creating a sum function


Below is an example of how to calculate the total of a sequence of numbers. In this case we will be calculating the sum of 10 + 9 + … + 2 + 1

Example:

sum(10);

Result:

55

Iterative version of a function that calculates the summation


To understand how to calculate the sum using recursion, let’s write a simple algorithm that will do it for us using iteration.

//Our initial total is zero
int total = 0;

//We want the sum from 1 + 2 + … + 9 + 10
int n = 10;

//The following for loop will calculate the summation from 1 – n
for ( int i = 1; i < = n; i++ ) {
     total = total + i;
}

Read more »

Google Wave Invitations

November 13th, 2009 | 15 Comments | Posted in Blog, Miscellaneous by Diego | - [Full Entry]

gwaveI recently got invited to the invite-only Google Wave and fortunately for you, I also got invitations to give out to you. But…wait a minute? What is Google Wave?

What is Google Wave?

According to their About Google Wave, Google Wave is an online tool for real-time communication and collaboration. It can be used to discuss and collaborate texts, photos, videos, maps, and so much more.

ss2

Google Wave Invitations

So how do I get one? Post a comment on why you should have an invitation in the comments and make sure you post your e-mail address correctly. Then, in a day or so, I’ll announce who gets an invitation. Simple as that.
Read more »

C++ Recursion – Printing a Sequence of Numbers in Reverse

November 6th, 2009 | 2 Comments | Posted in C++ by Diego | - [Full Entry]

Printing a sequence of numbers in reverse


Below is an example of how to reverse a sequence of numbers printed using a recursive function in C++.

10 9 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9 10

Printing numbers using recursion


To understand how to print a sequence of numbers in reverse, we first demonstrate a recursive function that displays a sequence of numbers in decreasing order.

void print(int n) {
    if ( n < = 0 ) return; //Terminating condition
         
     cout << n << " "; //Prints number n

     print(n-1); //Calls itself with (n-1)

     return; //Returns from the function
}

The code above is explained in Introduction to Recursion in C++.

Example:

 print(3); 

Produces:

3 2 1

Printing Numbers in Reverse


Now, how would you print out the previous sequence of numbers but in reverse order using recursion?

Think about it. The difference from the previous question and this one is the order in which the numbers are printed. This only requires a simple modification from the previous example.

Read more »

Programming Challenges

October 18th, 2009 | No Comments | Posted in Programming by Diego | - [Full Entry]

Programming Challenge

Practice for Programming Competitions using an online judge

Programming Challenges contains over 100 programming challenges found in multiple programming books that will provide you with an excellent resource for practicing for a programming competition or for simply polishing your skills.

The premise is simple. After signing up you simply choose a problem, read the description that contains sample input and ouput, and then submit it to an online judge. You then can submit your response in either C++, Java, or Pascal.

Upon submitting your answer, within seconds you should receive one of the following responses: Correct, Incorrect, Presentation Error, or Time Exceeded. You can retry the problem multiple times if you didn’t answer it correctly or go on to view statistics based on your submissions and of other users.
Read more »

Send and Receive free text messages with AIM

August 11th, 2009 | No Comments | Posted in Tips & Tricks by Diego | - [Full Entry]

Picture 4 Do you have AIM? Did you know you could send and receive free text messages? Yes, you heard me right. Free. Gratis. For nada. Sounds good doesn’t it?

Sending free text messages with AIM

First of all, you need an AIM account. Then simply add a contact beginning with +1 followed by their full number including area code. In order for people to send you text messages, you must send them a message, and have them save the incoming number to contact you in the future.

That’s it. You can send a free text message as long as the receiver’s carrier allows you to. Sometimes the receiver must accept incoming messages but its a one time procedure. The only down side is you must be connected in order to receive messages. If you aren’t, you’ll miss the text entirely.

Read more »

Beejive – Multi-Client Instant Messenger for iPhone

August 10th, 2009 | No Comments | Posted in iPhone & iPod Touch by Diego | - [Full Entry]

beejive1I was user of AIM with my iPod touch but lately all the crashing and lagging made me make the switch to Beejive. So far? I’m loving it.

Beejive is worth the $9.99

Sure, $9.99 does sound like a lot. Considering I don’t have a texting plan, I didn’t mind forking over the money. I was skeptical at first but it comes with a great variety of features.

  • Connect to Facebook, MySpace, AIM, Yahoo, Hotmail, and more…
  • Desktopish type of application – Comes will all types of features you’d expect out of a desktop application
  • Apply themes to conversations and the application itself
  • Push notifications alerting you of new messages
  • No lag and minimal crashing
  • Easy to switch over to conversations and preview last message your buddy sent
  • Overall, feels slick and sexy. Even the icon looks good on my home bar
  • Vertical and Horizontal typing. Your current typing in progress is displayed on a transparent bubble which optimizes your chatting viewing area.

So if you are looking for another instant messaging application on the iPhone/iPod Touch, try out Beejive. So far its been the best looking and working instant messaging application I’ve used.

Read more »

PhotoXpress – Free Stock Photography

July 14th, 2009 | No Comments | Posted in Resources Online by Diego | - [Full Entry]

Photo Express

PhotoXpress is another great stop for those looking for free stock photography. They currently offer over 410k photos that are available for download once you register for free.

So is PhotoXpress really free?

Yes, the only catch is you can only download one photo per day. Want to increase it? Then fill out your profile and you can download an additional 5 per day. If you want even more, connect your account with Facebook and it will grant you an additional 4 per day.

I’ll be trying it out as it seems an excellent resource as the images are great for using within posts, and layouts as well.

Read more »