本文目录一览:
- 如何用c语言画出y=sinx的图像。要求水平为x轴,竖直方向为y轴,不允许使用数学库。意思是要自己定义函数。
- c语言编程中,sinx怎么表示?
- C语言 输出sinx函数图像,要求用“*”,2个周期,有x、y轴。
- sinx的图像是什么
如何用c语言画出y=sinx的图像。要求水平为x轴,竖直方向为y轴,不允许使用数学库。意思是要自己定义函数。
#include<stdio.h>
#include<math.h>
#define pi 3.1415926
#define MAX_W 50000
main()
{
void sin_curv(int w, int h, int ang);
int w,h,ang;
scanf("%d %d %d", &w, &h, &ang);
sin_curv(w,h,ang);
return 0;
}
void sin_curv(int w, int h, int ang)
{
char str[MAX_W];
int s,i,j;
double d;
for(i=0; i<h; i++)
{
for(s=0; s<w; s++)
str[s] = ' ';
str[0] = '|';
str[w] = '\0';
if(i == h/2)
{
for(s=1; s<w; s++)
str[s] = '-';
}
for(j=0; j<w; j++)
{
d = j * ang / w * pi / 180.0;
if(i == (int)(h/2 - sin(d) * h/2))
str[j] = '*';
}
puts(str);
}
}
望采纳
c语言编程中,sinx怎么表示?
在写C语言的程序时,在开头加上一个头文件math.h
即可。
即可直接使用sin(x)
,特别注意x
应该为弧度制,如果不是弧度制需要转化为弧度制。
添加头文件方法:#include <math.h>
。
扩展资料:
在C语言家族程序中,头文件被大量使用。一般而言,每个C++/C程序通常由头文件和定义文件组成。头文件作为一种包含功能函数、数据接口声明的载体文件,主要用于保存程序的声明,而定义文件用于保存程序的实现。
C标准函数库(C Standard library)是所有符合标准的头文件(head file)的集合,以及常用的函数库实现程序,例如I/O 输入输出和字符串控制。
不像 COBOL、Fortran 和 PL/I等编程语言,在 C 语言的工作任务里不会包含嵌入的关键字,所以几乎所有的 C 语言程序都是由标准函数库的函数来创建的。
1995年,Normative Addendum 1 (NA1)批准了三个头文件(iso646.h
, wchar.h
, and wctype.h
)增加到C标准函数库中。C99标准增加了六个头文件(complex.h
, fenv.h
, inttypes.h
, stdbool.h
, stdint.h
, and tgmath.h
)。
C11标准中又新增了5个头文件(stdalign.h
, stdatomic.h
, stdnoreturn.h
, threads.h
, and uchar.h
)。至此,C标准函数库共29个头文件 。
常用的C语言函数库:
math.h
stdio.h
stdlib.h
time.h
string.h
使用方法:#include +函数库名
参考资料来源:百度百科 - C标准函数库
C语言 输出sinx函数图像,要求用“*”,2个周期,有x、y轴。
#include "graphics.h"
#include <stdio.h>
#include <conio.h>
#include <math.h>
void main()
{
int GD, GM;
int i, a, val;
GD = DETECT;
initgraph(&GD, &GM, "");
printf("请输入半幅高度10-200: ");
scanf("%d", &a);
setfillstyle(SOLID_FILL, WHITE);
bar(0, 0, 639, 479);
setcolor(BLACK);
line(20, 20, 20, 459); // y轴
line(15, 25, 20, 20);
line(25, 25, 20, 20);
outtextxy(16, 10, "Y");
line(20, 239, 620, 239); // x轴
line(615, 234, 620, 239);
line(615, 244, 620, 239);
outtextxy(625, 234, "X");
setcolor(RED);
for(i = 0; i < 560; i += 2) // 隔点输出*,可以根据梳密需要调整
{
val = a * sin(i * 4 * 3.14159 / 560);
outtextxy(i + 20, 239 + val, "*");
}
getch();
closegraph();
}
sinx的图像是什么
您好, sinx的图像如下: 下面介绍一下sinx的性质:
- 无极限
通过图观察,我们不难发现sinx的图像在区间(-∞,+∞)内总是趋于两个点即(x,1)和(x,-1),根据极限的定义可以知道,函数必须要不断的逼近某个点时才能称作为有极限,而sinx却同时趋近于两个点,故不满足定义,它是没有极限的。 - 周期函数
通过图观察,我们可以发现sinx在区间内不断波动,故其为周期性函数。