導航:首頁 > 源碼編譯 > acos源碼編譯

acos源碼編譯

發布時間:2022-11-14 11:12:13

A. 關於C++的acos函數

不要忘了頭文件 #include <math.h>
這取決於編譯器對未給初始值的變數的處理 -- 默認 0 還是給 不定值。
我用 MS VC++ 6.0 跑下面程序:
#include <stdio.h>
#include <math.h>
main(){
float a,b,c,d,e,f;
printf("%f %f\n",e,acos(e));
f =e;
printf("%f %f",f,acos(f));
}
輸出:
0.000000 1.570796
0.000000 1.570796

B. 我編了一個C語言小程序:輸入三角形的三邊長,求各角與面積。編譯時出了錯,但我發現不了,請問哪裡錯了

同學,你有幾點錯誤:
1. for循環之後,如果有{},那麼你的代碼不應該含有 "; ",如for(;;){}
2. 所有的for都應該在main裡面
3. printf("format",var, ...) 使用的是變數名,而不是地址
scanf("format", &varp,...) 使用的是變數地址!
你如果可以加強對C/C++語言的學習,就更好了 。 再努努力,你一定會成功的 :-)

下面是源代碼,最後面的注釋是調試輸出的結果:

/*
* thriArea.cc
*
* Created on: 2010-6-5
* Author: LiuFeng
* Email: [email protected]
*/
#include <cstdio>
#include <cmath>
#include <cassert>

#define PI 3.14159265
using namespace std;

int
main(void)
{
float arcs1[3],arcs2[3],S,length[3];
int i;
char al, A;
printf("\rPlease input: \n");

for(i=0,al='a';i<3;++i,++al) {
printf(" %c=",al); scanf("%f",&length[i]);
}

printf("\nAnswer: \r");
for(i=0,A='A'; i<3; ++i,++A){
arcs1[i]=acos((::pow(length[(i+1)%3],2.0)+::pow(length[(i+2)%3],2.0)-::pow(length[i%3],2.0))/2/length[(i+1)%3]/length[(i+2)%3]);
arcs2[i]=180/PI*arcs1[i];
}

S=(length[0]*length[1]*sin(arcs1[2]))/2;
printf("\n S=%-6.2f\n",S);

return 0;
}

/*
Output:

[Administrator@ /<7>06/05]$ g++ -g -O3 -Wall thriArea.cc -o gets
[Administrator@ /<7>06/05]$ ./gets.exe
Please input:
a=3
b=4
c=5

Answer:
S=6.00

[Administrator@ /<7>06/05]$

*/

C. 在c語言里怎麼辦輸入的弧度制轉化為角度值

(1)沒有 °符號的都是弧度制,換句話說,角度制一定有 °

(2)在高中數學中,若沒有特殊說明,都習慣用弧度製表示,弧度和角度的轉換式為

角度=(180°/π)*弧度

c語言源代碼如下:

#include<stdio.h>
#include<stdlib.h>

intmain(intargc,char*argv[])
{
constdoublepi=3.14159;
intjd;//角度值
doublehd;//弧度值
printf("請輸入角度值: ");
scanf("%d",&jd);
hd=jd*pi/180;
printf("對應的弧度值:%g ",hd);
system("pause");
return0;
}

D. arino如何輸出一個數組如位置坐標(x,y).不是賦值而是輸出。

可以試一下把println(x,y);改成:
print("("); print(x); print(","); print(y); println(")");
把數組拆分輸出

E. c語言源代碼

我見程序中有m = acos(y)*10一句。acos()出來的,肯定是一個浮點數。樓主不妨把x和m也修改為double型。

F. 用python編譯的一個題目,但為何一直提示最後一句SyntaxError: invalid syntax,一直沒找到錯誤在哪裡。

您好,在shell里運行的,您是在python里運行,自然會出錯了。
你直接打開命令行,然後就輸入
./MI-GRAALRunner.py testGraph1.gw testGraph2.gw result -p 3
就可以了,不能先進入python,至於是用python2還是python3運行,作者已經幫你設置好了。
shell指的是bash,不是python shell。python shell只能運行python語句,是不能運行這種命令的。
另外,建議你以後提問還是直接把所有錯誤信息一起復制了貼上來,那樣的話一看就能知道你是因為進入了python再執行才出錯的。

G. 怎樣用C語言編寫數學公式

1、C語言有現場的常用數學函數,所在函數庫為math.h、stdlib.h。

函數名及解釋:
int abs(int i) 返回整型參數i的絕對值
double cabs(struct complex znum) 返回復數znum的絕對值
double fabs(double x) 返回雙精度參數x的絕對值
long labs(long n) 返回長整型參數n的絕對值
double exp(double x) 返回指數函數ex的值
double frexp(double value,int *eptr) 返回value=x*2n中x的值,n存貯在eptr中
double ldexp(double value,int exp); 返回value*2exp的值
double log(double x) 返回logex的值
double log10(double x) 返回log10x的值
double pow(double x,double y) 返回xy的值
double pow10(int p) 返回10p的值
double sqrt(double x) 返回+√x的值
double acos(double x) 返回x的反餘弦cos-1(x)值,x為弧度
double asin(double x) 返回x的反正弦sin-1(x)值,x為弧度
double atan(double x) 返回x的反正切tan-1(x)值,x為弧度
double atan2(double y,double x) 返回y/x的反正切tan-1(x)值,y的x為弧度
double cos(double x) 返回x的餘弦cos(x)值,x為弧度
double sin(double x) 返回x的正弦sin(x)值,x為弧度
double tan(double x) 返回x的正切tan(x)值,x為弧度
double cosh(double x) 返回x的雙曲餘弦cosh(x)值,x為弧度
double sinh(double x) 返回x的雙曲正弦sinh(x)值,x為弧度
double tanh(double x) 返回x的雙曲正切tanh(x)值,x為弧度
double hypot(double x,double y) 返回直角三角形斜邊的長度(z),x和y為直角邊的長度,z2=x2+y2


2、復雜的數學函數可以用自定義函數的形式實現。

例如:

doubleConerVelocity(intA,doublex1,doubley1,doublex2,doubley2,doublet1,doublet2)
{
doubleT,V;
T=acos(abs(x1*x2+y1*y2)/sqrt(x1*x1+y1*y1)/sqrt(x2*x2+y2*y2));
V=(A*(t2-t1))/(2*sin(T/2));
returnV;
}

H. poj3122 為什麼用C++能過 但G++不能過 代碼里也沒什麼特別的函數什麼的啊。

你的文件名是什麼後綴,這個和編譯器有關
gcc為GNU Compiler Collection的縮寫,可以編譯C和C++源代碼等,它是GNU開發的C和C++以及其他很多種語言 的編譯器
g++也能編譯C源代碼,只不過把會把它當成C++源代碼,後綴為.c的,gcc把它當作是C程序,而g++當作是c++程序;後綴為.cpp的,兩者都會認為是c++程序,注意,雖然c++是c的超集,但是兩者對語法的要求是有區別的

I. error C2064: 項不會計算為接受 1 個參數的函數

1、編譯器錯誤 C2064
錯誤消息
項不會計算為接受「number」個參數的函數

一般出現這個錯誤是因為函數定義參數個數與實際調用參數個數不符合。

2、下面為C語言的錯誤大全及中文解釋:
1: Ambiguous operators need parentheses — 不明確的運算需要用括弧括起
2: Ambiguous symbol xxx — 不明確的符號
3: Argument list syntax error — 參數表語法錯誤
4: Array bounds missing — 丟失數組界限符
5: Array size toolarge — 數組尺寸太大
6: Bad character in paramenters — 參數中有不適當的字元
7: Bad file name format in include directive — 包含命令中文件名格式不正確
8: Bad ifdef directive synatax — 編譯預處理ifdef有語法錯
9: Bad undef directive syntax — 編譯預處理undef有語法錯
10: Bit field too large — 位欄位太長
11: Call of non-function — 調用未定義的函數
12: Call to function with no prototype — 調用函數時沒有函數的說明
13: Cannot modify a const object — 不允許修改常量對象
14: Case outside of switch — 漏掉了case 語句
15: Case syntax error — Case 語法錯誤
16: Code has no effect — 代碼不可能執行到
17: Compound statement missing{ — 分程序漏掉"{"
18: Conflicting type modifiers — 不明確的類型說明符
19: Constant expression required — 要求常量表達式
20: Constant out of range in comparison — 在比較中常量超出范圍
21: Conversion may lose significant digits — 轉換時會丟失意義的數字
22: Conversion of near pointer not allowed — 不允許轉換近指針
23: Could not find file xxx — 找不到XXX文件
24: Declaration missing ; — 說明缺少";"
25: Declaration syntax error — 說明中出現語法錯誤
26: Default outside of switch — Default 出現在switch語句之外
27: Define directive needs an identifier — 定義編譯預處理需要標識符
28: Division by zero — 用零作除數
29: Do statement must have while — Do-while語句中缺少while部分
30: Enum syntax error — 枚舉類型語法錯誤
31: Enumeration constant syntax error — 枚舉常數語法錯誤
32: Error directive :xxx — 錯誤的編譯預處理命令
33: Error writing output file — 寫輸出文件錯誤
34: Expression syntax error — 表達式語法錯誤
35: Extra parameter in call — 調用時出現多餘錯誤
36: File name too long — 文件名太長
37: Function call missing ) — 函數調用缺少右括弧
38: Fuction definition out of place — 函數定義位置錯誤
39: Fuction should return a value — 函數必需返回一個值
40: Goto statement missing label — Goto語句沒有標號
41: Hexadecimal or octal constant too large — 16進制或8進制常數太大
42: Illegal character x — 非法字元x
43: Illegal initialization — 非法的初始化
44: Illegal octal digit — 非法的8進制數字 A
45: Illegal pointer subtraction — 非法的指針相減
46: Illegal structure operation — 非法的結構體操作
47: Illegal use of floating point — 非法的浮點運算
48: Illegal use of pointer — 指針使用非法
49: Improper use of a typedefsymbol — 類型定義符號使用不恰當
50: In-line assembly not allowed — 不允許使用行間匯編
51: Incompatible storage class — 存儲類別不相容
52: Incompatible type conversion — 不相容的類型轉換
53: Incorrect number format — 錯誤的數據格式
54: Incorrect use of default — Default使用不當
55: Invalid indirection — 無效的間接運算
56: Invalid pointer addition — 指針相加無效
57: Irrecible expression tree — 無法執行的表達式運算
58: Lvalue required — 需要邏輯值0或非0值
59: Macro argument syntax error — 宏參數語法錯誤
60: Macro expansion too long — 宏的擴展以後太長
61: Mismatched number of parameters in definition — 定義中參數個數不匹配
62: Misplaced break — 此處不應出現break語句
63: Misplaced continue — 此處不應出現continue語句
64: Misplaced decimal point — 此處不應出現小數點
65: Misplaced elif directive — 不應編譯預處理elif
66: Misplaced else — 此處不應出現else
67: Misplaced else directive — 此處不應出現編譯預處理else
68: Misplaced endif directive — 此處不應出現編譯預處理endif
69: Must be addressable — 必須是可以編址的
70: Must take address of memory location — 必須存儲定位的地址
71: No declaration for function xxx — 沒有函數xxx的說明
72: No stack — 缺少堆棧
73: No type information — 沒有類型信息
74: Non-portable pointer assignment — 不可移動的指針(地址常數)賦值
75: Non-portable pointer comparison — 不可移動的指針(地址常數)比較
76: Non-portable pointer conversion — 不可移動的指針(地址常數)轉換
77: Not a valid expression format type — 不合法的表達式格式
78: Not an allowed type — 不允許使用的類型
79: Numeric constant too large — 數值常太大
80: Out of memory — 內存不夠用
81: Parameter xxx is never used — 能數xxx沒有用到
82: Pointer required on left side of -> — 符號->的左邊必須是指針
83: Possible use of xxx before definition — 在定義之前就使用了xxx(警告)
84: Possibly incorrect assignment — 賦值可能不正確
85: Redeclaration of xxx — 重復定義了xxx
86: Redefinition of xxx is not identical — xxx的兩次定義不一致
87: Register allocation failure — 寄存器定址失敗
88: Repeat count needs an lvalue — 重復計數需要邏輯值
89: Size of structure or array not known — 結構體或數給大小不確定
90: Statement missing ; — 語句後缺少";"
91: Structure or union syntax error — 結構體或聯合體語法錯誤
92: Structure size too large — 結構體尺寸太大
93: Sub scripting missing ] — 下標缺少右方括弧
94: Superfluous & with function or array — 函數或數組中有多餘的"&"
95: Suspicious pointer conversion — 可疑的指針轉換
96: Symbol limit exceeded — 符號超限
97: Too few parameters in call — 函數調用時的實參少於函數的參數不
98: Too many default cases — Default太多(switch語句中一個)
99: Too many error or warning messages — 錯誤或警告信息太多
100: Too many type in declaration — 說明中類型太多
101: Too much auto memory in function — 函數用到的局部存儲太多
102: Too much global data defined in file — 文件中全局數據太多
103: Two consecutive dots — 兩個連續的句點
104: Type mismatch in parameter xxx — 參數xxx類型不匹配
105: Type mismatch in redeclaration of xxx — xxx重定義的類型不匹配
106: Unable to create output file xxx — 無法建立輸出文件xxx
107: Unable to open include file xxx — 無法打開被包含的文件xxx
108: Unable to open input file xxx — 無法打開輸入文件xxx
109: Undefined label xxx — 沒有定義的標號xxx
110: Undefined structure xxx — 沒有定義的結構xxx
111: Undefined symbol xxx — 沒有定義的符號xxx
112: Unexpected end of file in comment started on line xxx — 從xxx行開始的註解尚未結束文件不能結束
113: Unexpected end of file in conditional started on line xxx — 從xxx 開始的條件語句尚未結束文件不能結束
114: Unknown assemble instruction — 未知的匯編結構
115: Unknown option — 未知的操作
116: Unknown preprocessor directive: xxx — 不認識的預處理命令xxx
117: Unreachable code — 無路可達的代碼
118: Unterminated string or character constant — 字元串缺少引號
119: User break — 用戶強行中斷了程序
120: Void functions may not return a value — Void類型的函數不應有返回值
121: Wrong number of arguments — 調用函數的參數數目錯
122: xxx not an argument — xxx不是參數
123: xxx not part of structure — xxx不是結構體的一部分
124: xxx statement missing ( — xxx語句缺少左括弧
125: xxx statement missing ) — xxx語句缺少右括弧
126: xxx statement missing ; — xxx缺少分號
127: xxx declared but never used — 說明了xxx但沒有使用
128: xxx is assigned a value which is never used — 給xxx賦了值但未用過

J. 在<math.h>中有哪些函數

相關函數 labs, fabs

表頭文件 #include<stdlib.h>

定義函數 int abs (int j)

函數說明 abs()用來計算參數j的絕對值,然後將結果返回。

返回值 返回參數j的絕對值結果。

範例 #ingclude <stdlib.h>
main(){
int ansert;
answer = abs(-12);
printf("|-12| = %d\n", answer);
}

執行 |-12| = 12



acos(取反餘弦函數數值)
相關函數 asin , atan , atan2 , cos , sin , tan

表頭文件 #include <math.h>

定義函數 double acos (double x);

函數說明 acos()用來計算參數x的反餘弦值,然後將結果返回。參數x范圍為-1至1之間,超過此范圍則會失敗。

返回值 返回0至PI之間的計算結果,單位為弧度,在函數庫中角度均以弧度來表示。

錯誤代碼 EDOM參數x超出范圍。

附加說明 使用GCC編譯時請加入-lm。

範例 #include <math.h>
main (){
double angle;
angle = acos(0.5);
printf("angle = %f\n", angle);
}

執行 angle = 1.047198



asin(取反正弦函數值)
相關函數 acos , atan , atan2 , cos , sin , tan

表頭文件 #include <math.h>

定義函數 double asin (double x)

函數說明 asin()用來計算參數x的反正弦值,然後將結果返回。參數x范圍為-1至1之間,超過此范圍則會失敗。

返回值 返回-PI/2之PI/2之間的計算結果。

錯誤代碼 EDOM參數x超出范圍

附加說明 使用GCC編譯時請加入-lm

範例 #include<math.h>
main()
{
double angle;
angle = asin (0.5);
printf("angle = %f\n",angle);
}

執行 angle = 0.523599



atan(取反正切函數值)
相關函數 acos,asin,atan2,cos,sin,tan

表頭文件 #include<math.h>

定義函數 double atan(double x);

函數說明 atan()用來計算參數x的反正切值,然後將結果返回。

返回值 返回-PI/2至PI/2之間的計算結果。

附加說明 使用GCC編譯時請加入-lm

範例 #include<math.h>
main()
{
double angle;
angle =atan(1);
printf("angle = %f\n",angle);
}

執行 angle = 1.570796

閱讀全文

與acos源碼編譯相關的資料

熱點內容
python字元串中符號 瀏覽:785
python正則表達式貪婪模式 瀏覽:648
愛國精神指的是什麼app 瀏覽:408
壽司解壓系列全集視頻 瀏覽:913
物體三維重建演算法 瀏覽:984
fuli直播app哪個好 瀏覽:918
租辦公室用什麼app 瀏覽:106
醫師定期考核刷題app哪個好 瀏覽:338
導出dmp文件命令 瀏覽:288
手機百度網盤怎麼解壓密碼文件 瀏覽:585
索引重新編譯 瀏覽:606
命令與征服4免cd補丁完美版 瀏覽:428
kotlin編譯為native 瀏覽:142
家用編譯機 瀏覽:552
電子加密貨幣最新政策 瀏覽:382
androidcanvas撤銷 瀏覽:272
安卓手機怎麼把圖標全部下移 瀏覽:187
飢荒被伺服器踢出怎麼進 瀏覽:173
c編譯器哪款好 瀏覽:734
快手寶哥發明什麼app 瀏覽:823