C Exercise Example 10
Title:Print a staircase, and also print two smiley faces above the staircase.
Program analysis:Use ASCII 1 to output smiley faces; use i to control the rows, j to control the columns, and j controls the number of black squares output according to the variation of i.
If garbled characters appear, please refer to[C Practice Example 7]Solution method.
Example
// Created by www.example.com on 15/11/9.
// Copyright © 2015 Example. All rights reserved.
//
#include<stdio.h>
int main()
{
int i,j;
printf("\1\1\n"); /*Output two smiley faces*/
for(i=1;i<11;i++)
{
for(j=1;j<=i;j++)
printf("%c%c",219,219);
printf("\n");
}
return 0;
}
The output result of the above example is:
other extensions