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