質問編集履歴

1

修正依頼を直した

2023/07/02 04:31

投稿

michikusa-mc
michikusa-mc

スコア26

test CHANGED
File without changes
test CHANGED
@@ -10,3 +10,37 @@
10
10
  - C++で扱える
11
11
 
12
12
  特にツールなどの制限は問いませんので、ご意見よろしくお願いします!
13
+
14
+ ## 追記:試したこと
15
+ 「調査したこと・試したことが記載されていない質問」とご指摘を受けました。ありがとうございます。
16
+ - 数値を文字列として扱う
17
+ ```c++
18
+ #include <iostream>
19
+ #include <vector>
20
+ using namespace std;
21
+
22
+ int main(void) {
23
+ string n = "1234789452315541318781321897897451354894865132189485616579845646546515649845848915618948691891978943216549846135486748465";
24
+ cout << n << endl;
25
+ return 0;
26
+ }
27
+ ```
28
+ この方法は無理矢理なうえに、計算アルゴリズムが大変な事になるので止めました。
29
+ - unsigned __int64を複数使用する方法
30
+ ```c++
31
+ #include <iostream>
32
+ #include <vector>
33
+ using namespace std;
34
+
35
+ int main(void) {
36
+ __int64 x = 12345678987654321;
37
+ __int64 y = 1234567890;
38
+
39
+ // 123456789876543211234567890
40
+ cout << x << y << endl;
41
+ return 0;
42
+ }
43
+ ```
44
+ この方法がいいと思ったのですが、円周率を計算するプログラムなので扱いにくいので断念。
45
+
46
+ 初心者ですみませんが、改めてご意見お願いします。