/ 猿问

# 怎么用javascript语言编程一个爱心形状呢 ?

2019-05-29 21:07:07

# 怎么用javascript语言编程一个爱心形状呢

## 4 回答

 1234567891011121314151617181920212223242526272829 Untitled Document

var canvas = document.getElementById("canvas1");var ctx = canvas.getContext("2d");ctx.translate(300,300); //sets center in the middle of the picturedrawHeart(); function drawHeart() {   ctx.beginPath();   ctx.moveTo(0,-100);   ctx.bezierCurveTo(120,-300, 300,-100, 200,50);   ctx.lineTo(0,250);   ctx.lineTo(-200,50);   ctx.bezierCurveTo(-300,-100, -120,-300, 0,-100);   ctx.closePath();   ctx.fillStyle="#ff0000";   ctx.fill();}

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

# define U 0.06
# define V 0.025

# define M 1.1
# define N 1.2

int main(void)
{
float x, y;
float m, n;
char a[6600];
for ( y=2; y>=-2; y-=U )
{
for ( x=-1.2; x<=1.2; x+=V)
{
if ( ( ( (x*x + y*y - 1)*(x*x + y*y - 1)*(x*x + y*y - 1) - x*x*y*y*y ) <= 0 ) )
strcat(a,"*");
else
strcat(a," ");
}
strcat(a,"\n");
}
strcat(a,"\0");
printf("%s\n",a);
getchar();

return 0;
}

#include<stdio.h>
int n;
void draw(int n)
{
int i,j;
for (i=1-(n>>1);i<=n;i++)
if (i>=0)
{
for (j=0;j<i;j++) printf(" ");
for (j=1;j<=2*(n-i)+1;j++) printf(" *");
printf("\n");
}
else
{
for (j=i;j<0;j++) printf(" ");
for (j=1;j<=n+2*i+1;j++) printf(" *");
for (j=1;j<=-1-2*i;j++) printf(" ");
for (j=1;j<=n+2*i+1;j++) printf(" *");
printf("\n");
}
}
int main()
{
scanf("%d",&n);
draw(n);
return 0;
}

#include<stdio.h>
int n;
void draw(int n)
{
int i,j;
for (i=1-(n>>1);i<=n;i++)
if (i>0)
{
for (j=0;j<i;j++) printf(" ");
for (j=1;j<=2*(n-i)+1;j++)
if (j==1||j==2*(n-i)+1) printf(" *");
else printf(" ");
printf("\n");
}
else
if (i==0)
{
printf(" *");
for (j=1;j<n;j++) printf(" ");
printf(" *");
for (j=1;j<n;j++) printf(" ");
printf(" *\n");
}
else
{
for (j=i;j<0;j++) printf(" ");
for (j=1;j<=n+2*i+1;j++)
if (i==1-(n>>1)) printf(" *");
else if (j==1||j==n+2*i+1) printf(" *");
else printf(" ");
for (j=1;j<=-1-2*i;j++) printf(" ");
for (j=1;j<=n+2*i+1;j++)
if (i==1-(n>>1)) printf(" *");
else if (j==1||j==n+2*i+1) printf(" *");
else printf(" ");
printf("\n");
}
}
int main()
{
scanf("%d",&n);
draw(n);
return 0;
}

/*

* *
* * *
* *
*

*/

#include <stdio.h>

int main()
{
int a[4][7] ={{0,1,0,0,0,1,0},{1,0,0,1,0,0,1},{0,1,0,0,0,1,0},{0,0,0,1,0,0,0}};
for(int i=0;i<4;i++) /*输出行*/
{
for(int j=0;j<7;j++) /*输出列*/
{
if(a[i][j] !=0)
printf("*");
else
printf(" ");
}
printf("\n");
}

return 0;
}
//这是我用索引数组的方法写的。
//如果你需要其它的版本可以告 * 诉我。

• 4 回答
• 0 关注
• 912 浏览

0/150