HAPPY NEW YEAR!

It seems like it was only yesterday when I drew my first “for loop shape” in my introductory Java class and felt like a GODDESS. 

Now, here I am, doing the same kind of stuff in C++ and still having fun (…not feeling a bit ashamed).

Anyway, just copy and paste the code here (or just click here) and see what happens!

(If you are on a mobile device, click here in order to have a meaningful shape).

#include <iostream>
using namespace std;

int main(){
  int size;
  cout << "What do you want the size of your \"shape\" to be?";
  cout << " (pls no funny input) ";   cin >> size;
  
  while(size < 2 || size > 50){
    cout << "I SAID NO FUNNY INPUT!!" << endl;
    cout << "What do you want the size of your \"shape\" to be?";
    cout << " (pls no funny input) ";     cin >> size;
  }
      int i;
      
      for(i=0; i<size-1; i++)
        cout << " ";
      
      cout << "**" << endl;
      
      for(i=0; i<size; i++){
        int j;
        
        for(j=0; j<size-1-i; j++)
            cout << " ";
        
        for(j=0; j<i+1; j++)
            cout << "/";
        
        for(j=0; j<i+1; j++)
            cout << "\\";
        
        cout << endl;    
      }
      
      for(i=0; i<size-1; i++){
          cout << " ";
      }
      
      cout << "||" << endl;
  
  return 0;
}

HAPPY NEW YEAR!

 

Advertisements

4 thoughts on “HAPPY NEW YEAR!

  1. I had my degree from Istanbul Technical University (civil eng.). It is great that computer engineering is becoming one of the genderless professions.

    Prof. Judy Hoyt from MIT gives a precise speech to encourage to pursue a career in engineering. I provided the link below.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s