当前位置:网站首页>C language confession code?
C language confession code?
2022-07-31 04:01:00 【Programming fish six six six】
Problem-solving ideas: I have divided this example into 4 parts, part of the first 3 lines, part of lines 4-6, part of lines 7-13, and part of the last line. Readers please read the notes carefully.Xiaolin wrote very detailed.
The first three lines of output, just to let beginners know that even the dumbest method can be printed.
Lines 4-6, these three lines have the same output effect.
for(i=0;i<3;i++){for(j=0;j<29;j++){printf("*");}printf("\n");}
Last line, just output a *.
for(i=0;i<14;i++){printf(" ");}printf("*\n");
Source code demo: Please refer to the above screenshots for the first three lines of code style. The source code spaces in the article are a little buggy:
#include//Header fileint main()//main function entry{printf("**** ****\n");//Print the first lineprintf(" ********* *********\n");//Print the second lineprintf("**************** *************\n");//Print the third lineint i,j;//Define variablesfor(i=0;i<3;i++)//Print 4-6 lines, a total of 3 lines, so i is less than 3{for(j=0;j<29;j++)//limit the number of output * per line{printf("*");//These three lines only print *, no spaces}printf("\n");//After printing a line, you need to wrap}for(i=0;i<7;i++) //Print 7-13 lines, a total of 7 lines, so i is less than 7{for(j=0;j<2*(i+1)-1;j++)//This for loop is parallel to the following for{printf(" ");//print spaces}for(j=0;j<27-i*4;j++)//The reader can bring in several numbers to find the conditions{printf("*");//print*}printf("\n");}for(i=0;i<14;i++)//Print the * of the last line{printf(" ");//print spaces}printf("*\n") ;//print*return 0;}
Compiling and running results are as follows:
The * in the above code can be replaced by the reader. The reader can try to replace it with this symbol to see if it is feasible, and think about it by yourself.
The second kind of confession source code demonstration:
#include//Header file#include//In order to refer to the pow functionint main()//main function entry{float y, x, z;//Define floating point variablesprintf("I think of you when I'm alone\n");//Prompt statementprintf("I want to hug you when I cry\n");//Prompt statementprintf("I want to pounce on you when I'm happy\n");//Prompt statementprintf("I want to kiss you when I'm excited\n");//Prompt statementprintf("Everything is done in the three-word signature without signing\n");//Prompt statementprintf("\n");//Newlinefor (double y = 2.5; y >= -1.6; y = y - 0.2){for (double x = -3; x <= 4.8; x = x + 0.1){//The following is a ternary operation, please read carefully, || this is or(pow((x*x + y*y - 1), 3) <= 3.6*x*x*y*y*y|| (x>-2.4 && x<-2.1 && y<1.5 && y>-1)|| (((x<2.5 && x>2.2) || (x>3.4 && x<3.7)) && y>-1 && y<1.5)|| (y>-1 && y<-0.6 && x<3.7 && x>2.2)) ? printf("*") : printf(" ");}printf("\n");//Newline}getchar();return 0;//The return value of the function is 0}
The results of compilation and running are as follows:
There are many ways to print a heart shape in C language. Readers can try more by themselves. Even using printf line by line is also a way. I can only help you here. My girlfriend still has to find it by herself./p>
The above, if you read the above and think it is helpful to you, please give the editor a thumbs up, so that the editor will also have the motivation to update, thank you all the folks~~
em>C language C++ programming and programming learning baseQQ group: 828339809[Click to enter]
Organize and share (source code of many years of study, project actual combat video, project notes, basic introductory tutorial)
Welcome partners who change careers and learn programming, learn and grow faster with more information than pondering on your own!
边栏推荐
- Safety 20220715
- Summary of Huawei Distributed Storage FusionStorage Knowledge Points [Interview]
- $attrs/$listeners
- MySQL 8.0.30 GA
- Distributed locks and three implementation methods
- LeetCode每日一练 —— OR36 链表的回文结构
- (tree) Last Common Ancestor (LCA)
- IDEA common shortcut keys and plug-ins
- mysql基础知识(二)
- 端口排查步骤-7680端口分析-Dosvc服务
猜你喜欢
Daily practice of LeetCode - palindrome structure of OR36 linked list
[Dynamic programming] Maximum sum of consecutive subarrays
Unity2D 自定义Scriptable Tiles的理解与使用(四)——开始着手构建一个基于Tile类的自定义tile(下)
浅识Flutter 基本组件之CheckboxListTile组件
「 每日一练,快乐水题 」1331. 数组序号转换
立足本土,链接全球 | 施耐德电气“工业SI同盟”携手伙伴共赴未来工业
LocalDate addition and subtraction operations and comparison size
从滴滴罚款后数据治理思考
MATLAB/Simulink&&STM32CubeMX工具链完成基于模型的设计开发(MBD)(三)
扫雷游戏(c语言写)
随机推荐
Safety 20220722
递归实现汉诺塔问题
【AUTOSAR-RTE】-4-Port和Interface以及Data Type
立足本土,链接全球 | 施耐德电气“工业SI同盟”携手伙伴共赴未来工业
Know the showTimePicker method of the basic components of Flutter
Redis counts new and retained users
BUG definition of SonarQube
[C language] General method of base conversion
Notes on the establishment of the company's official website (6): The public security record of the domain name is carried out and the record number is displayed at the bottom of the web page
"DeepJIT: An End-To-End Deep Learning Framework for Just-In-Time Defect Prediction" paper notes
(tree) Last Common Ancestor (LCA)
【C语言进阶】文件操作(一)
The use of beforeDestroy and destroyed
(6) Enumeration and annotation
Good place to download jar packages
type_traits元编程库学习
[C language] Preprocessing operation
MySQL 8.0.30 GA
Port inspection steps - 7680 port analysis - Dosvc service
Detailed explanation of TCP (2)