您用c语言程序画过画?用c语言程序画个爱“心”,祝大家春节愉快,身体健康,平安吉祥,牛气冲天!顺便温习一下c语言编写,及运行正确姿势

前言

在这辞旧迎新的时刻,az_debugIT提前给您拜年啦️,您及全家春节愉快,身体健康,平安吉祥!冲天!

Today is the Eve of  lunar year of 2020. Everyone may either got so much or remain regreted about something in 2020. Anyway it is the past year,a frufilful year for everyone. We will have bravery and  change rather than fear and complaint in the new year. We can make differences , make believe and make available in the new year.
Happy Chinese New Year!
今天是除夕,回首过去的一年,也许你收获满满,也许仍心怀遗憾。凡是过往,皆为序章,新的一年,让我们告别怯懦,更加勇敢;告别抱怨,尝试改变;告别浮躁,变得更好。牛年将至,让我们整装出发,拥抱更多可能。新年快乐!

学习很多语言,java、scala、golang、python,背后都要c语言的影子,大学那时候,基础学的也是c语言,借此用满满的爱心,通过一个有趣的c语言程序,温习一下c语言编写,及运行正确姿势。

正题

简单安装环境依赖

 不像以前学习c语言,在windows下还要什么编译环境,及IDE……现在linux环境一大把,安装上软件工具,就可以用……

yum -y install gcc gcc-c++ kernel-devel

 画“心”c程序

vim heart.c

输入一下代码 

#include <stdio.h>
#include <math.h>

int main()
{

 float x, y, f;
 for(y = 1.6; y >= -1.6; y -= 0.15){
 for(x = -1.1; x <= 1.1; x += 0.05){
  f = x*x + pow(y - pow(x*x, 1.0/3), 2) - 1; //函数方程

  putchar(f <= 1E-5 ? '*' : ' ');
 }

 putchar('\n');
 }

 for(y = 1.6; y >= -1.6; y -= 0.15){
 for(x = -1.1; x <= 1.1; x += 0.05){
  f = x*x + pow(y - pow(x*x, 1.0/3), 2) - 1; //函数方程

  putchar(f > 1E-5 ? '*' : ' ');
 }

 putchar('\n');
 }

 return 0;
}

保存关闭。

编译heart.c

gcc heart.c -lm -o heart

通过-lm链接到math.h库
-o 是输出为执行文件heart

执行“执行程序”

[root@oracledb ~]# ./heart

结尾

新年,辞旧迎新,用“心”,给大家拜年:

祝大家新年快乐!
在新的一年里牛气十足、牛转乾坤、牛运冲天  牛年大吉、牛市亨通、牛年你最牛!

Happy Chinese New Year!
It's the Year of the Ox, a symbol for hard work and diligence, so this year is good for careers and fortune. May you find success this year!

猜你喜欢

转载自blog.csdn.net/as4589sd/article/details/113791233