質問編集履歴

3

追加

2022/07/10 22:27

投稿

sinnjinndesuga
sinnjinndesuga

スコア0

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,66 @@
1
1
  構造体へのポインタの受け渡し方をよく理解していないため、このような書き方しかできませんでした。ド素人質問で申し訳ないのですが、下記のプログラムを手直ししていただけないでしょうか。
2
2
  答えが表示すらされない状況です。
3
3
  returnとprintV3とprintfをちょこちょこいじったのでさらにわからなくなりました。
4
+
5
+ エラーコード
6
+ ??.c: In function ‘v3k’:
7
+ ??.c:40:9: warning: ‘return’ with a value, in function returning void
8
+ 40 | return ( r);
9
+ | ^
10
+ ??.c:34:6: note: declared here
11
+ 34 | void v3k( double k, V3 *p, V3 *r)
12
+ | ^~~
13
+ ??.c: In function ‘v2k’:
14
+ ??.c:45:18: warning: implicit declaration of function ‘v3abs’ [-Wimplicit-function-declaration]
15
+ 45 | r->wx = p->wx / v3abs( p);
16
+ | ^~~~~
17
+ ??.c: At top level:
18
+ ??.c:50:8: error: conflicting types for ‘v3abs’
19
+ 50 | double v3abs( V3 *p)
20
+ | ^~~~~
21
+ ??.c:45:18: note: previous implicit declaration of ‘v3abs’ was here
22
+ 45 | r->wx = p->wx / v3abs( p);
23
+ | ^~~~~
24
+ ??.c: In function ‘v3t’:
25
+ ??.c:57:16: warning: implicit declaration of function ‘v3ip’ [-Wimplicit-function-declaration]
26
+ 57 | return( acos( v3ip( p, q) / v3abs( p) * v3abs( q)));
27
+ | ^~~~
28
+ ??.c: In function ‘v3cp’:
29
+ ??.c:66:9: warning: ‘return’ with a value, in function returning void
30
+ 66 | return ( r);
31
+ | ^
32
+ ??.c:60:6: note: declared here
33
+ 60 | void v3cp( V3 *p, V3 *q, V3 *r)
34
+ | ^~~~
35
+ ??.c: At top level:
36
+ ??.c:69:8: error: conflicting types for ‘v3ip’
37
+ 69 | double v3ip( V3 *p, V3 *q)
38
+ | ^~~~
39
+ ??.c:57:16: note: previous implicit declaration of ‘v3ip’ was here
40
+ 57 | return( acos( v3ip( p, q) / v3abs( p) * v3abs( q)));
41
+ | ^~~~
42
+ ??.c: In function ‘main’:
43
+ ??.c:93:10: warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘double *’
44
+ -Wformat=]
45
+ 93 | scanf("%d", &k);
46
+ | ~^ ~~
47
+ | | |
48
+ | | double *
49
+ | int *
50
+ | %le
51
+ ??.c:94:9: warning: too many arguments for format [-Wformat-extra-args]
52
+ 94 | printf("定数倍 k * a", &c);
53
+ | ^~~~~~~~~~~~~~~~~
54
+ ??.c:96:2: warning: implicit declaration of function ‘v3u’; did you mean ‘v3t’? [-Wimplicit-function-declaration]
55
+ 96 | v3u(&a, &c);
56
+ | ^~~
57
+ | v3t
58
+ ??.c:106:19: warning: format ‘%f’ expects argument of type ‘double’, but argument 2 has type ‘struct _v3 *’ [-Wformat=]
59
+ 106 | printf("外積%.2f", &c);
60
+ | ~~~^ ~~
61
+ | | |
62
+ | | struct _v3 *
63
+ | double
4
64
 
5
65
 
6
66
  「三次元ベクトルを表す構造体を定義して、この構造体の演算のための関数を作る」

2

追加

2022/07/10 22:06

投稿

sinnjinndesuga
sinnjinndesuga

スコア0

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,8 @@
1
1
  構造体へのポインタの受け渡し方をよく理解していないため、このような書き方しかできませんでした。ド素人質問で申し訳ないのですが、下記のプログラムを手直ししていただけないでしょうか。
2
+ 答えが表示すらされない状況です。
3
+ returnとprintV3とprintfをちょこちょこいじったのでさらにわからなくなりました。
4
+
5
+
2
6
  「三次元ベクトルを表す構造体を定義して、この構造体の演算のための関数を作る」
3
7
 
4
8
  ```

1

修正

2022/07/10 22:06

投稿

sinnjinndesuga
sinnjinndesuga

スコア0

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,7 @@
1
1
  構造体へのポインタの受け渡し方をよく理解していないため、このような書き方しかできませんでした。ド素人質問で申し訳ないのですが、下記のプログラムを手直ししていただけないでしょうか。
2
2
  「三次元ベクトルを表す構造体を定義して、この構造体の演算のための関数を作る」
3
3
 
4
+ ```
4
5
  //------- 3次元ベクトルを扱うプログラム
5
6
  #include <stdio.h>
6
7
  #include<math.h>