Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 KB | None | 0 0
  1. void drawX(int size) {
  2.     int situation = 0; //used to go to a certain if statement or the else
  3.     int star2 = 1; //the 2nd star, this changes because the middle of the X does not have a 2nd star
  4.     int space = 0; //the spaces on the left side
  5.     int space2 =((size*2)-3); //the spaces on the right side
  6.     int counter = 0; //makes sure the X is the appropriate size according to the user
  7.     int cutoff = ((size*2)-1); //where the line should get cut off
  8.    
  9.     while(counter < cutoff){ //cutoff also acts as a double-value variable - it is also how high the X should be
  10.  
  11.         if (space2<=0){  //if we're in the middle of the X
  12.             star2=0;
  13.             situation=1;
  14.         }
  15.  
  16.         else //if we're not in the middle of the X, the 2nd star still exists
  17.         star2=1;
  18.  
  19.         writePattern(' ', '*', ' ', '*', ' ', space, 1, space2, star2, space, cutoff);
  20.  
  21.         if(situation == 0){ //if we're creating the 'V' shape
  22.             space++;
  23.             space2 = (space2-2);
  24.         }
  25.  
  26.         else{ //if we're creating the ^ shape
  27.             space--;
  28.             space2 = (space2+2);
  29.         }
  30.         ++counter; //keep track of how large the shape is getting, when it hits the max the loop ends
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement