Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

mario cs50

#include <cs50.h>
#include <stdio.h>

int main(void)
{
    int steps;

    // get steps num
    do

    {
        steps = get_int("How tall do you want your pyramid to be? Enter a number between 1-8 (inclusive): ");
    }

    while ((steps >= 1 && steps <= 8) == false);

    // for each step in the pyramid
    for (int i = 1; i <= steps; i++)
    {
        /* for each brick in the step */

        // format to make the text look like a pyramid
        for (int k = 0; k < (steps - i); k++)
        {
            printf(" ");
        }

        // left side of step
        for (int j = 0; j < i; j++)
        {
            printf("#");
        }

        // sep
        printf("  ");

        // right side of step
        for (int j = 0; j < i; j++)
        {
            printf("#");
        }

        printf("
");
    }
}
Comment

PREVIOUS NEXT
Code Example
Python :: save image from jupyter notebook 
Python :: np one hot encoding 
Python :: creating a pandas df 
Python :: read emails from gmail python 
Python :: print all attributes of object python 
Python :: how to open pickle file 
Python :: How to select rows in a DataFrame between two values, in Python Pandas? 
Python :: combination 
Python :: python access global variable 
Python :: how to make a random variable in python 
Python :: flask setup 
Python :: how to find the data type in python 
Python :: pandas where 
Python :: print pretty in python 
Python :: count item in list python 
Python :: how to change size of turtle in python 
Python :: Python program to print all odd numbers in a range 
Python :: doc2vec similarity 
Python :: python mixins 
Python :: python set remove multiple elements 
Python :: basic games to code in python 
Python :: pandas map using two columns 
Python :: how to read numbers in csv files python 
Python :: maxsize in python 
Python :: generate binay image python 
Python :: python numpy array size of n 
Python :: data structures and algorithms in python 
Python :: how to read multiple csv file from different directory in python 
Python :: django check user admin 
Python :: python one line if statement no else 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =