c語言正弦
㈠ c語言中sin怎麼輸入
C語言sin()用來計算參數x 的正玄值,然後將結果返回。返回-1 至1 之間的計算結果。
例子:
#include <math.h>
main(){
double answer = sin(0.5);
printf("sin(0.5) = %f ", answer);
}
執行
sin(0.5) = 0.479426
C語言sin():
sin()原型:double sin(double x)
sin()角度與弧度:
π=180°
1°=π/180
1(rad)=180/π
角度轉弧度:用角度乘以π/180
弧度轉角度:用弧度乘以180/π,或者用rtod()函數
(1)c語言正弦擴展閱讀:
與sin相似的acos函數
函數名: acos
功 能:計算並返回arccos(x)值、要求-1<=X<=1
函數與形參類型:
double acos(x)
double x;
程序例:
#include <stdio.h>
#include <math.h> int main(void)
{
double result;
double x = 0.5; result = acos(x);
printf("The arc cosine of %lf is %lf ", x, result);
return 0;
}
㈡ C語言怎麼編寫正弦波
源代碼如下:
#include#include#define EX 0.000001
#define PI 3.14159265
int main()
{
double x=0.0, temp=1.0, sin=0.0;
int i;
printf("Please input a degree:");
scanf("%lf",&x);
x=x*PI/180;
temp=x;i=0 ;
while ( fabs(temp) >EX ) ...{
sin += temp;
i += 2;
temp = (-1) * temp*x*x/( (i+1)*(i) );
}
printf("sin(%lf) = %lf ",x,sin);
printf("The number is %d ",i);
return 0;
}
(2)c語言正弦擴展閱讀
C語言編寫一個程序輸出一個正方形的源代碼如下:
#include
intmain()
{
inti,j,n;
scanf("%d",&n);
for(i=0;i
printf("*");
else
printf("");
}
printf(" ");
}
return0;
}
㈢ c語言畫正弦函數
首先,你輸出的不是正弦圖像,而是反正弦圖像。
#include<stdio.h>
#include<math.h>
int
main(){
double
y;
int
x,m,i;
printf("y=sin(x)
[0<x<2*pi]\n");
for(y=1;y>=-1;y-=0.1){//表示y的取值范圍是[-1,1]
if(y>=0){
m=asin(y)*10;
//反正弦函數,確定空格的數量,最大值為15
for(x=1;x<m;x++)printf("
");
//printf("*",m);
printf("*");//注意此時不換行,因為後面還有一個點
for(;x<31-m;x++)printf("
");//輸出第二個點,並換行
printf("*\n");}
else{//同理輸出y小於0的點
m=-1*asin(y)*10;
for(i=0;i<32;i++)printf("
");
for(x=1;x<m;x++)printf("
");
//printf("*",m);
printf("*");
for(;x<31-m;x++)printf("
");
printf("*\n",m);
}
}
getchar();
return
0;
}
㈣ C語言中正弦函數
doublesin(doublex);
sin參數為double類型,返回值也為double
#include<stdio.h>
#include<math.h>
intmain()
{
constdoublepi=3.1415926;
doubled,e;
scanf("%f",&d);
e=sin(2*pi*d/63.84);
printf("%lf ",e);
return0;
}
㈤ C語言sin怎麼用
C語言sin()用來計算參數x 的正玄值,然後將結果返回。返回-1 至1 之間的計算結果。
例子:
#include <math.h>
main(){
double answer = sin(0.5);
printf("sin(0.5) = %f ", answer);
}
執行
sin(0.5) = 0.479426
C語言sin():
sin()原型:double sin(double x)
sin()角度與弧度:
π=180°
1°=π/180
1(rad)=180/π
角度轉弧度:用角度乘以π/180
弧度轉角度:用弧度乘以180/π,或者用rtod()函數
(5)c語言正弦擴展閱讀:
與sin相似的acos函數
函數名: acos
功 能:計算並返回arccos(x)值、要求-1<=X<=1
函數與形參類型:
double acos(x)
double x;
程序例:
#include <stdio.h>
#include <math.h> int main(void)
{
double result;
double x = 0.5; result = acos(x);
printf("The arc cosine of %lf is %lf ", x, result);
return 0;
}
㈥ 請問sin函數是什麼意思,在c語言有什麼作用。
sin函數是正弦函數,在C語言中用來求角度的sin值。
在直角三角形ABC中,∠C是直角,AB是∠c斜邊,BC是∠A的對邊,AC是∠B的對邊。正弦函數就是sin(A)=a/c。
(6)c語言正弦擴展閱讀
對於任意一個實數x都對應著唯一的角(弧度制中等於這個實數),而這個角又對應著唯一確定的正弦值sinx,這樣,對於任意一個實數x都有唯一確定的值sinx對應。
在[-(π/2)+2kπ,(π/2)+2kπ],k∈Z上是增函數
在[(π/2)+2kπ,(3π/2)+2kπ],k∈Z上是減函數
最大值:當x=2kπ+(π/2) ,k∈Z時,y(max)=1
最小值:當x=2kπ+(3π/2),k∈Z時,y(min)=-1
㈦ 用c語言編寫程序求正弦
我用c-free試了一下,將getch()改成getchar就可以運行了,然後sin x 中的x指的是弧度,而不是角度,所以改了之後就可以運行了,結果是對的。不過我也明白為什麼x的指比較大的時候就不能得到准確的答案
㈧ 怎樣用c語言畫正弦函數
1、首先,打開VS2019,並且創建一個C語言源文件,會看到如下的頁面。
㈨ 如何用C語言中專門的數學演算法實現正弦,餘弦函數的計算
頭文件包含。math.h
cos
:餘弦函數
函數原型:double
cos(double
x);
頭文件:#include<math.h>
是否是標准函數:是
函數功能:求x的餘弦值,這里,x為弧度。
返回值:計算結果的雙精度值。
常式如下:
求cosx。
#include
<stdio.h>
#include
<math.h>
int
main(void)
{
double
result;
double
x
=
M_PI;
result
=
cos(x);
printf("cos(PI)
is
%lf\n",
result);
return
0;
}
sin:正弦函數
函數原型:double
sin(double
x);
頭文件:#include<math.h>
是否是標准函數:是
函數功能:求x的正弦值,這里,x為弧度。
返回值:計算結果的雙精度值。
常式如下:
求sinx。
#include
<stdio.h>
#include
<math.h>
int
main(void)
{
float
x;
x=M_PI/2;
printf("sin(PI/2)=%f",sin(x));
getchar();
return
0;
}