Notes on C language brushing questions - printing smiley faces

insert image description here

Article directory

topic

Print the stairs and at the same time print two smiley faces above the stairs.

insert image description here

ideas

Use i to control the row, j to control the column, and j to control the number of output black squares according to the change of i.

Note that the numbers 128 to 255 are extended codes and are not originally used for display. Change the code page of the console that executes this program to 437.

answer

#include <stdio.h>
#include <windows.h>

int main()
{
    
    
    int i,j;
    SetConsoleOutputCP(437);

    printf("\1\1\n");   //输出两个笑脸

    for(i=1;i<11;i++)
    {
    
    
        for(j=1;j<=i;j++)
        {
    
    
            printf("%c%c",219,219);
        }

        printf("\n");
    }

}

Sample output

insert image description here

insert image description here

Guess you like

Origin blog.csdn.net/qq_21484461/article/details/123998371