teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

一部訂正いたしました

2021/02/24 13:57

投稿

yukiiwashiro
yukiiwashiro

スコア0

title CHANGED
File without changes
body CHANGED
@@ -4,6 +4,8 @@
4
4
  ビジュアルスタジオをつかってC++の課題をしているのですが、
5
5
  coutで文字入力を行った直後ディバックがなぜか終了してしまいます。
6
6
 
7
+ このプログラムは、2つの数字を入れて頂いて、その一つ目を二進数で表すものなのですが、2つ目の数字をいれた途端にディバックが終了し、2進数が表示されません。
8
+
7
9
  色々試しましたがプログラミングに不慣れなせいもあり、まったく原因がわかりません。
8
10
  教えて頂けると幸いです。
9
11
 
@@ -36,19 +38,19 @@
36
38
  long long LocInt3;
37
39
  long long unsigned LocInt1;
38
40
  cout << endl << endl;
39
- cout << endl << "\tEnter an unsigned integer: ";
41
+ cout << endl << "\tいくつかの数字を入力してください: ";
40
42
  while (!(cin >> LocInt3)) {
41
- cout << "\tInvalid input; reenter: ";
43
+ cout << "\t正しくないです: ";
42
44
  cin.clear();
43
45
  cin.ignore(256, '\n');
44
46
  }
45
47
  if (LocInt3 < 0L) {
46
48
  LocInt1 = LocInt3 * -1L;
47
- cout << "\tYou entered a negative value; converting to positive: " << LocInt1 << endl << endl;
49
+ cout << "\tマイナスが入力されました; プラスにへんこうします: " << LocInt1 << endl << endl;
48
50
  }
49
51
  else {
50
52
  LocInt1 = LocInt3;
51
- cout << "\tYou entered: " << LocInt1 << endl << endl;
53
+ cout << "\tあなたが入力した数字は: " << LocInt1 << endl << endl;
52
54
  }
53
55
 
54
56
  long long LocInt2;
@@ -57,34 +59,29 @@
57
59
  cout << endl << "\tEnter an second unsigned integer: ";
58
60
  while (!(cin >> LocInt2 ) || LocInt2 <LocInt1) {
59
61
  if(LocInt2 < LocInt1){
60
- cout << "\tEnter value should greater than the first integer: ";
62
+ cout << "\t1回目よりも大きな数字にして下さい: ";
61
63
  }
62
64
  else {
63
- cout << "\tInvalid input; reenter: ";
65
+ cout << "\t正しくないです; reenter: ";
64
66
  }
65
67
  cin.clear();
66
68
  cin.ignore(256, '\n');
67
69
  }
68
70
  if (LocInt2 < 0L) {
69
71
  LocInt4 = LocInt2 * -1L;
70
- cout << "\tYou entered a negative value; converting to positive: " << LocInt4 << endl << endl;
72
+ cout << "\tマイナスが入力されました; プラスにへんこうします: " << LocInt4 << endl << endl;
71
73
  }
72
74
  else {
73
75
  LocInt4 = LocInt2;
74
- cout << "\tYou entered: " << LocInt4 << endl << endl;
76
+ cout << "\tあなたが入力した数字は: " << LocInt4 << endl << endl;
75
77
 
76
78
  }
77
79
 
78
- long long LocIntSum;
79
- LocIntSum = LocInt4 + LocInt1;
80
- cout << LocIntSum;
81
80
 
82
-
83
81
  cout << "First Integer";
84
- cout << << binary(LocInt1) << endl;
82
+ cout << "2進数に変換した数値は:" << binary(LocInt1) << endl;
85
83
  return 0;
86
84
 
87
- }
88
85
  ```
89
86
 
90
87
  ### 試したこと