C程序:编写在屏幕上画出正弦曲线的函数

C程序:编写在屏幕上画出正弦曲线的函数,第1张

#include<stdio.h>

#include<冲举math.h>

main(){

double y

int x,m,i

printf("y=sin(x) [0<x<2*pi]\n")

for(y=1y>=-1y-=0.1){

if(y>=0){

m=asin(y)*10

for(x=1x<mx++)printf(" ")

printf("*",m)

for(x<31-mx++)printf(" "乱判判)

printf("*\n")}

else{

m=-1*asin(y)*10

for(i=0i<32i++)printf(" ")

for(x=1x<mx++)printf(" "哗改)

printf("*",m)

for(x<31-mx++)printf(" ")

printf("*\n",m)

}

}

}

在matlab中,可以用plot函数来绘制函数曲线。举例说明如下:

% 画出一条正弦曲线和一条余弦曲线。

>> x=0:pi/10:2*pi

>> y1=sin(x)

>> y2=cos(x)

>> plot(x,y1,x,y2) 告辩% x,y1表示横纵坐标(sin函数),x,y2表示横纵坐标(cos函数袜颤缺)

以上洞卜程序绘制的图形如下:

这个是玫瑰花程序!你可以借鉴!

#include <stdio.h>

#include <dos.h>

#include <graphics.h>

/*花儿*/

void hua(int x,int y)

{

register i

setcolor(12)

arc(x+65,y-60,150,350,8)

arc(x+66,y-54,300,470,8)

arc(x+65,y-56,30,230,10)

arc(x+64,y-57,300,460,17)

ellipse(x+73,y-30,250,450,27,40)

ellipse(x+59,y-30,100,290,27,40)

ellipse(x+65,y-40,140,270,20,30)

setfillstyle(SOLID_FILL,5)

floodfill(x+65,y-20,12)

arc(x,y,150,350,12)

arc(x+1,y+8,280,470,12)

arc(x,y+2,30,230,16)

arc(x,y+3,80,240,28)

arc(x+2,y+8,180,330,22)

arc(x-2,y+2,310,460,25)

ellipse(x-12,y+30,120,300,30,40)

ellipse(x+10,y+28,250,423,30,42)

ellipse(x-4,y+10,290,393,30,40)

setfillstyle(SOLID_FILL,4)

floodfill(x+5,y+31,12)

ellipse(x+120,y+5,0,360,15,25)

setfillstyle(SOLID_FILL,15)

floodfill(x+120,y,12)

ellipse(x-70,y+10,0,360,14,20)

setfillstyle(SOLID_FILL,14)

floodfill(x-70,y+10,12)

setcolor(10)

ellipse(x-15,y+32,190,310,30,35)

ellipse(x+16,y+32,235,355,26,35)

ellipse(x,y+35,190,350,43,50)

arc(x,y+82,190,350,6)

setfillstyle(SOLID_FILL,2)

floodfill(x,y+75,10)

ellipse(x+50,y-48,190,320,22,50)

ellipse(x+80,y-48,220,350,22,50)

ellipse(x+65,y-28,180,360,36,50)

floodfill(x+65,y+18,10)

for(i=0i<3i++)

{

ellipse(x-98,y+100+i,255,371,100,80)

ellipse(x-20,y+30+i,260,358,140,140)

ellipse(x+233,y+20+i,180,218,160,140)

}

ellipse(x+70,y+34,180,233,140,140)

ellipse(x,y+40,205,255,100,120)

ellipse(x+135,y-30,209,249,72,120)

ellipse(x,y+20,263,301,100,120)

ellipse(x+85,y-10,278,305,100,120)

ellipse(x+100,y-62,282,308,90,120)

ellipse(x-50,y-10,277,314,30,120)

ellipse(x+70,y+80,222,266,52,120)

ellipse(x-60,y-45,229,266,52,120)

ellipse(x+79,y-45,229,266,52,120)

ellipse(x+84,y,224,273,52,120)

ellipse(x+110,y+40,240,282,100,120)

ellipse(x+120,y-6,200,340,17,25)

ellipse(x+120,y+7,160,380,17,27)

ellipse(x-70,y+15,140,380,17,20)

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12460856.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-25
下一篇 2023-05-25

发表评论

登录后才能评论

评论列表(0条)

保存