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

質問編集履歴

3

<code>ボタンの使用

2019/12/09 02:39

投稿

okure_man
okure_man

スコア7

title CHANGED
File without changes
body CHANGED
@@ -10,6 +10,7 @@
10
10
 
11
11
  エラーは出ないが、while文がループしてくれない。
12
12
  ### 該当のソースコード
13
+ ```ここに言語を入力
13
14
  #include <bits/stdc++.h>
14
15
  using namespace std;
15
16
 
@@ -34,6 +35,7 @@
34
35
  if(count<N)
35
36
  cout<<count<<endl;
36
37
  }
38
+ ```
37
39
 
38
40
  ### 試したこと
39
41
 

2

誤字の修正、質問に関係ない部分の削除

2019/12/09 02:39

投稿

okure_man
okure_man

スコア7

title CHANGED
File without changes
body CHANGED
@@ -16,13 +16,11 @@
16
16
  int main() {
17
17
  int N;
18
18
  cin >>N;
19
- vector<int> vec(N);
19
+ vector<int> vec(N);
20
-
21
20
  for(int i=0;i<N;i++){
22
21
  cin >> vec.at(i);
23
- //cout<<vec.at(i)<<endl;
24
22
  }
25
- int i;
23
+ int i =0;
26
24
  int count = 0;
27
25
 
28
26
  while(vec.at(i) != 2){

1

for 文をwhile 文(質問原文)に訂正。

2019/12/09 02:31

投稿

okure_man
okure_man

スコア7

title CHANGED
File without changes
body CHANGED
@@ -25,7 +25,7 @@
25
25
  int i;
26
26
  int count = 0;
27
27
 
28
- for(int j=0; vec.at(i) != ;j++){
28
+ while(vec.at(i) != 2){
29
29
  i = vec.at(i)-1;//3
30
30
  count++;
31
31
  cout<<vec.at(i)<<endl;