Simple heart-shaped code in c language
Use c language to create a heart-shaped pattern. For beginners of C language.
Recommended learning: c language video tutorial
The code is as follows:
#include <stdio.h> int main() { for (float y = 1.5f; y > -1.5f; y -= 0.1f) { for (float x = -1.5f; x < 1.5f; x += 0.05f) { float a = x * x + y * y - 1; putchar(a * a * a - x * x * y * y * y <= 0.0f ? '*' : ' '); } putchar(' '); } }
Running effect:
For more programming-related tutorials, please pay attention to PHP Chinese website!
The above is the detailed content of Simple heart code in c language. For more information, please follow other related articles on the PHP Chinese website!