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

質問編集履歴

5

誤字

2020/09/22 08:12

投稿

physics303
physics303

スコア89

title CHANGED
File without changes
body CHANGED
@@ -20,7 +20,7 @@
20
20
  #include <cstdlib>
21
21
 
22
22
  int main(int argc, char* argv[]){
23
- int rank = atoi( argv[1] )
23
+ int rank = atoi( argv[1] );
24
24
  hogehoge
25
25
  }
26
26
  ```

4

コードの全容を入力

2020/09/22 08:12

投稿

physics303
physics303

スコア89

title CHANGED
File without changes
body CHANGED
@@ -27,4 +27,31 @@
27
27
 
28
28
  ### 環境
29
29
 
30
- CentOS, Bash
30
+ CentOS, Bash
31
+
32
+
33
+ ### 追記
34
+ 問題を簡潔にするために,shellscriptの一部だけを取り出していましたが,問題のshellscriptの全容は以下です.以下のコードでrank引数がうまくいかない理由を考えているのです.
35
+
36
+ ```shell.sh
37
+ int cnt=0;
38
+ int noise_level=0;
39
+ int dataset_number=0;
40
+ int sample_size=100;
41
+ int rank=5;
42
+ for ((i=0 ; i<sample_size; i++))
43
+ do
44
+ for ((j=0 ; j<i+1 ; j++))
45
+ do
46
+ cnt=$((cnt+1));
47
+ if [ $cnt = 75 ]; then
48
+ wait
49
+ cnt=0;
50
+ fi
51
+ echo $((rank));
52
+ ./a.out 0 0 opt $i $j $rank&
53
+ done
54
+ done
55
+ wait
56
+
57
+ ```

3

文法のミスを指摘

2020/09/22 08:09

投稿

physics303
physics303

スコア89

title CHANGED
File without changes
body CHANGED
@@ -5,6 +5,7 @@
5
5
  ```run.sh
6
6
  int rank=0
7
7
  for ((rank=0 ; rank<10; rank++))
8
+ do
8
9
  ./a.out $rank&
9
10
  done
10
11
  wait

2

環境追加

2020/09/22 08:01

投稿

physics303
physics303

スコア89

title CHANGED
File without changes
body CHANGED
@@ -22,4 +22,8 @@
22
22
  int rank = atoi( argv[1] )
23
23
  hogehoge
24
24
  }
25
- ```
25
+ ```
26
+
27
+ ### 環境
28
+
29
+ CentOS, Bash

1

rankの値が0になってしまうことを追記

2020/09/22 07:52

投稿

physics303
physics303

スコア89

title CHANGED
File without changes
body CHANGED
@@ -10,7 +10,7 @@
10
10
  wait
11
11
  ```
12
12
 
13
- ただ,これでは正常にrankの値が渡されていないようです.何が問題でしょうか.
13
+ ただ,これでは正常にrankの値が渡されていないようです.プログラムではrankが全て0として処理されているようです.何が問題でしょうか.
14
14
 
15
15
 
16
16
  なお,C++の中では,コマンドライン引数を次のように受け取っています.