当前位置:网站首页>C语言表白代码?
C语言表白代码?
2022-07-31 03:57:00 【编程小鱼六六六】
解题思路:这道例题我分了4部分,前3行一部分,4-6行一部分,7-13行一部分,最后一行一部分,读者请仔细阅读注释,小林写的很详细了。
前三行输出,为了让初学者知道,即使最笨的方法也是可以打印的。
4-6行,这三行输出效果一样。
for(i=0;i<3;i++)
{
for(j=0;j<29;j++)
{
printf("*");
}
printf("\n");
}
最后一行,只是输出一个*。
for(i=0;i<14;i++)
{
printf(" ");
}
printf("*\n");
源代码演示:前三行代码样式请参考上述截图,文章中的源码空格有点小bug:
#include<stdio.h>//头文件
int main()//主函数入口
{
printf(" **** ****\n");//打印第一行
printf(" ********* *********\n");//打印第二行
printf("************* *************\n");//打印第三行
int i,j;//定义变量
for(i=0;i<3;i++)//打印4-6行,一共3行,因此i小于3
{
for(j=0;j<29;j++)//限制每行输出*的个数
{
printf("*");//这三行只打印*号,无空格输出
}
printf("\n");//打印完一行需要进行换行
}
for(i=0;i<7;i++) //打印7-13行,一共7行,因此i小于7
{
for(j=0;j<2*(i+1)-1;j++)//这个for循环和下面的for是并列的
{
printf(" ");//打印空格
}
for(j=0;j<27-i*4;j++)//读者可以带入几个数找出条件
{
printf("*");//打印*
}
printf("\n");
}
for(i=0;i<14;i++)//打印最后一行的*
{
printf(" ");//打印空格
}
printf("*\n") ;//打印*
return 0;
}
编译运行结果如下:
上述代码中的*,读者可以自行替换,读者可以用这个符号替换试试,看是否可行,自己动脑思考一下。
第二种表白源代码演示:
#include<stdio.h>//头文件
#include<math.h>//为了引用pow函数
int main()//主函数入口
{
float y, x, z;//定义浮点型变量
printf("独时想起你\n");//提示语句
printf("落泪时想搂住你\n");//提示语句
printf("开心时想扑向你\n");//提示语句
printf("兴奋时想吻你\n");//提示语句
printf("一切尽在这三个字签名没有签上\n");//提示语句
printf("\n");//换行
for (double y = 2.5; y >= -1.6; y = y - 0.2)
{
for (double x = -3; x <= 4.8; x = x + 0.1)
{
//下面是个三目运算,读者请仔细看下,||这个是或
(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");//换行
}
getchar();
return 0;//函数返回值为0
}
编译运行结果如下:
C语言打印出心形的方法有很多,读者可以自己多尝试尝试,即使一行一行用printf也是一种方式,小编能帮你的只能到这了,女朋友还是要自己找
以上,如果你看了觉得对你有所帮助,就给小编点个赞叭,这样小编也有更新下去的动力,跪谢各位父老乡亲啦~~
C语言C++编程编程学习基地QQ群:828339809【点击进入】
整理分享(多年学习的源码、项目实战视频、项目笔记,基础入门教程)
欢迎转行和学习编程的伙伴,利用更多的资料学习成长比自己琢磨更快哦!
边栏推荐
- binom二项分布,
- Unity2D 自定义Scriptable Tiles的理解与使用(四)——开始着手构建一个基于Tile类的自定义tile(下)
- 【AUTOSAR-RTE】-4-Port and Interface and Data Type
- 高等数学---第九章二重积分
- (4) Recursion, variable parameters, access modifiers, understanding main method, code block
- Pytest e-commerce project combat (on)
- Good place to download jar packages
- 顺序表的实现
- Can‘t load /home/Iot/.rnd into RNG
- 5. How does the SAP ABAP OData service support the $filter operation
猜你喜欢
[C language] Three-pointed chess (classic solution + list diagram)
Mysql 45 study notes (twenty-five) MYSQL guarantees high availability
Unity2D 自定义Scriptable Tiles的理解与使用(四)——开始着手构建一个基于Tile类的自定义tile(下)
$attrs/$listeners
数据库实现分布式锁
C language from entry to such as soil, the data store
[C language] General method for finding the sum of the greatest common factor and the least common multiple of two integers m and n, the classical solution
Postgresql 15 source code analysis (5) - pg_control
立足本土,链接全球 | 施耐德电气“工业SI同盟”携手伙伴共赴未来工业
What is a system?
随机推荐
[AUTOSAR-RTE]-5-Explicit (explicit) and Implicit (implicit) Sender-Receiver communication
What skills do I need to learn to move from manual testing to automated testing?
微软 AI 量化投资平台 Qlib 体验
Component pass value provide/inject
Smartcom Programming Level 4 - Magic Academy Lesson 6
[Swift]自定义点击APP图标弹出的快捷方式
浅识Flutter 基本组件之showDatePicker方法
volatile内存语义以及实现 -volatile写和读对普通变量的影响
endian mode
SIP Protocol Standard and Implementation Mechanism
(8) Math class, Arrays class, System class, Biglnteger and BigDecimal classes, date class
[C language] General method for finding the sum of the greatest common factor and the least common multiple of two integers m and n, the classical solution
浅识Flutter 基本组件之CheckBox组件
(八)Math 类、Arrays 类、System类、Biglnteger 和 BigDecimal 类、日期类
els block to the left to move the conditional judgment
ClickHouse:设置远程连接
PMP WeChat group daily exercises
(六)枚举、注解
【SemiDrive源码分析】【MailBox核间通信】44 - 基于Mailbox IPCC RPC 实现核间通信(RTOS侧 IPCC_RPC Server 消息接收及回复 原理分析篇)
A brief introduction to the CheckboxListTile component of the basic components of Flutter