Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void drawX(int size) {
- int situation = 0; //used to go to a certain if statement or the else
- int star2 = 1; //the 2nd star, this changes because the middle of the X does not have a 2nd star
- int space = 0; //the spaces on the left side
- int space2 =((size*2)-3); //the spaces on the right side
- int counter = 0; //makes sure the X is the appropriate size according to the user
- int cutoff = ((size*2)-1); //where the line should get cut off
- while(counter < cutoff){ //cutoff also acts as a double-value variable - it is also how high the X should be
- if (space2<=0){ //if we're in the middle of the X
- star2=0;
- situation=1;
- }
- else //if we're not in the middle of the X, the 2nd star still exists
- star2=1;
- writePattern(' ', '*', ' ', '*', ' ', space, 1, space2, star2, space, cutoff);
- if(situation == 0){ //if we're creating the 'V' shape
- space++;
- space2 = (space2-2);
- }
- else{ //if we're creating the ^ shape
- space--;
- space2 = (space2+2);
- }
- ++counter; //keep track of how large the shape is getting, when it hits the max the loop ends
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement