Title: Print stairs and print two smiling faces above the stairs.
1. Program analysis: Use i to control rows, j to control columns, and j controls the number of black squares output according to the change of i.
2. Program source code:
#include "stdio.h"
main()
{
int i,j;
printf("\1\1\n");/*Output two smiling faces*/
for(i=1;i<11;i++)
{
for(j=1;j<=i;j++)
printf("%c%c",219,219);
printf("\n");
}
}
Title: Output a chess board. 1. Program analysis: Use i to control rows, j to control columns, and output black or white squares based on the sum of i+j. 2. Program source code: #include "stdio.h" main() { int i,j; for(i=0;i<8;i++) { for(j=0;j<8;j++) if((i+j)%2==0) printf("%c%c",219,219); else printf(" "); printf("\n"); } } |
Title: Output 9*9 formula.
1. Program analysis: Consider rows and columns, a total of 9 rows and 9 columns, i controls rows, j controls columns.
2. Program source code:
#include "stdio.h"
main()
{
int i,j,result;
printf("\n");
for (i=1;i<10;i++)
{ for(j=1;j<10;j++)
{
result=i*j;
printf("%d*%d=%-3d",i,j,result);/*-3d means left alignment, occupies 3 digits*/
}
printf("\n");/*New line after each line*/
}
}
Title: Output special patterns. Please run it in C environment and take a look. Very Beautiful!
1. Program analysis: There are 256 characters in total. Different characters have different patterns.
2. Program source code:
#include "stdio.h"
main()
{
char a=176,b=219;
printf("%c%c%c%c%c%c\n",b,a,a,a,b);
printf("%c%c%c%c%c%c\n",a,b,a,b,a); printf("%c%c%c%c%c%c\n",a,a,b,a,a);
printf("%c%c%c%c%c%
c\n",a,b,a,b,a); printf("%c%c%c%c%c%c\n",a,b,a,b,a);
printf("%c%c%c%c%c%c\n",b,a,a,a,b);}
Title: Use the * symbol to output the pattern of the letter C. 1. Program analysis: You can first use the * symbol to write the letter C on paper, and then output it in separate lines. 2. Program source code: #include "stdio.h" main() { printf("Hello C-world!\n"); printf(" ****\n"); printf(" *\n"); printf(" * \n"); printf(" ****\n"); } |
Previous article:Classic C Program (20/20)
Next article:Classic C Program (18/20)
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- Help car navigation Wince 6.0 system no boot prompt sound
- Yole's forecast for the RF market
- HyperLynx High-Speed Circuit Design and Simulation (I) Transmission Line Impedance and Power Supply Impedance Equal Reflection Experiment
- ESP32-S2-Saola-1 Firmware and Download Software
- PADS commonly used shortcut keys and some tips
- Creating an IoT-based Industrial Gateway Using Sitara AM437x Processor PoM (IoT-SDK)
- Wiring diagram of Hall current sensor
- TI's microcontroller I8669/I44445 (MCU) MSP430
- SystemVerilog and Functional Verification
- MATLAB and FPGA Implementation of Digital Filters (2nd Edition)