1171
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 #include <stdio.h>
|
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 #include "SchedTask.h"
|
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 #include "PrintTask.h"
|
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 #include "Func.h"
|
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5
|
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 SchedDefineTask1(PrintTask, print);
|
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7
|
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 static int
|
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 print(SchedTask *smanager, void *rbuf, void *wbuf)
|
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 {
|
1189
|
11 int length = (long)smanager->get_param(0); /* 出力する範囲 */
|
1171
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 int *input = (int*)smanager->get_input(rbuf, 0); /* 出力する配列 */
|
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13
|
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 /* 素数の判定結果が1ならば出力する */
|
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 for (int i = 0; i < length; i++) {
|
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 if ( input[i] == 1 ) {
|
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 printf("%d ",i);
|
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 }
|
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 }
|
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 printf("\n");
|
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 return 0;
|
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 }
|