爱心代码
来源:互联网 发布:淘宝兼职在哪里找 编辑:程序博客网 时间:2024/04/28 20:07
#include<stdio.h> #include<math.h> #include<stdlib.h>#define I 20 //爱心的上半部分两个小半圆的半径#define R 340 //爱心的下半部分圆弧曲线半径int main() {FILE *fp;if((fp=fopen("爱心.txt","w"))==NULL){ printf("File open error!\n"); exit(0);} int i,j,e; int a; //爱心的上半部分 为两个实心半圆 for(i=1,a=I;i<I/2;i++,a--){ for(j=(int) ( I-sqrt((double)(I*I-(a-i)*(a-i))) );j>0;j--) { printf(" "); fprintf(fp,"%s"," "); } for(e=1;e<=2*sqrt((double)(I*I-(a-i)*(a-i)));e++) { printf("\3"); fprintf(fp,"%s","*"); } for(j=(int) ( 2*( I-sqrt((double)(I*I-(a-i)*(a-i))) ) );j>0;j--) { printf(" "); fprintf(fp,"%s"," "); } for(e=1;e<=2*sqrt( (double) (I*I-(a-i)*(a-i)) );e++) { printf("\3"); fprintf(fp,"%s","*"); } printf("\n"); fprintf(fp,"%s","\n"); } //爱心的中间一行 可以打印一些标记 for(i=1;i<80;i++) { if(i==25) { printf(" I LOVE YOU!O(∩_∩)O~ "); fprintf(fp,"%s"," I LOVE YOU!O(∩_∩)O~ "); i+=30; } printf("\3"); fprintf(fp,"%s","*"); } printf("\n"); fprintf(fp,"%s","\n"); //爱心的下半部分 以R为半径的左右两条圆弧曲线 R设置为比较大 for(i=1;i<=R/2;i++){ if(i%2||i%3)continue;//因为R很大 两条曲线应该删去中间的一些点 这样就会更像爱心 for(j=(int) ( R-sqrt( (double) (R*R-i*i) ) );j>0;j--) { printf(" "); fprintf(fp,"%s"," "); } for(e=1;e<=2*( sqrt( (double)(R*R-i*i) ) - (R-2*I) );e++) { printf("\3"); fprintf(fp,"%s","*"); } printf("\n"); fprintf(fp,"%s","\n"); } //以下是以time做时间变量来控制变色//懒得查时间变量函数 故用这种超耗cpu的算法代替//最好不要这么写 以下代码仅供娱乐long time; for(; ;) { system("color a"); for(time=0;time<99999999;time++); system("color b"); for(time=0;time<99999999;time++); system("color c"); for(time=0;time<99999999;time++); system("color d"); for(time=0;time<99999999;time++); system("color e"); for(time=0;time<99999999;time++); system("color f"); for(time=0;time<99999999;time++); system("color 0"); for(time=0;time<99999999;time++); system("color 1"); for(time=0;time<99999999;time++); system("color 2"); for(time=0;time<99999999;time++); system("color 3"); for(time=0;time<99999999;time++); system("color 4"); for(time=0;time<99999999;time++); system("color 5"); for(time=0;time<99999999;time++); system("color 6"); for(time=0;time<99999999;time++); system("color 7"); for(time=0;time<99999999;time++); system("color 8"); for(time=0;time<99999999;time++); system("color 9"); for(time=0;time<99999999;time++); system("color ab"); for(time=0;time<99999999;time++); system("color ac"); for(time=0;time<99999999;time++); system("color ad"); for(time=0;time<99999999;time++); system("color ae"); for(time=0;time<99999999;time++); system("color af"); for(time=0;time<99999999;time++);} return 0;}
0 0
- 爱心代码
- 爱心代码
- 一个爱心闪烁代码
- 几行代码画爱心
- 爱心
- 爱心
- 爱心
- HTML代码之爱心树表白
- 程序中的浪漫---爱心的代码
- 六行python代码的爱心曲线
- c语言-爱心代码的实现
- 【python 可视化】python 一行代码画爱心图
- 爱心围墙
- 《爱心树》
- 爱心捐款
- 爱心编程
- 爱心图案
- 爱心桃
- UVA 1511 Soju(贪心)
- Qemu Vhost Block架构分析(上)
- Help is needed for Dexter
- 如何用Maven创建web项目(具体步骤)
- 深入理解C++的动态绑定和静态绑定
- 爱心代码
- Hdu1102 - Constructing Roads - 最小生成树
- 问答网站
- 如何保存Yum安装的软件包
- poj-1287 Networking 最小生成树
- 深入浅出 Java Concurrency: 线程池--线程池任务拒绝策略
- 初来北漂,黑中介“诈”道,58、赶集租房网缺
- KMP
- MYSQL REPEATABLE-READ隔离级别