Mercurial > hg > Game > Cerium
annotate example/Prime/ppe/PrintTask.cc @ 1248:d2f70da2aa19 draft
merge
author | Daichi Toma <toma@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 12 Nov 2011 15:32:41 +0900 |
parents | 9df036b11eae |
children | 24d323dfebea |
rev | line source |
---|---|
1171 | 1 #include <stdio.h> |
2 #include "SchedTask.h" | |
3 #include "PrintTask.h" | |
4 #include "Func.h" | |
5 | |
6 SchedDefineTask1(PrintTask, print); | |
7 | |
8 static int | |
9 print(SchedTask *smanager, void *rbuf, void *wbuf) | |
10 { | |
1232 | 11 long print_flag = (long)smanager->get_param(1); //プリントするかどうか |
1194
7909536bf611
fix Prime/PrintTask
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1189
diff
changeset
|
12 |
7909536bf611
fix Prime/PrintTask
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1189
diff
changeset
|
13 if (print_flag < 0) { |
7909536bf611
fix Prime/PrintTask
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1189
diff
changeset
|
14 return 0; |
7909536bf611
fix Prime/PrintTask
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1189
diff
changeset
|
15 } |
7909536bf611
fix Prime/PrintTask
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1189
diff
changeset
|
16 |
1232 | 17 long length = (long)smanager->get_param(0); /* 出力する範囲 */ |
18 bool *input = (bool*)smanager->get_input(rbuf, 0); /* 出力する配列 */ | |
1171 | 19 |
1243 | 20 input[0] = false; |
21 input[1] = false; | |
22 | |
1171 | 23 /* 素数の判定結果が1ならば出力する */ |
1232 | 24 for (long i = 0; i < length; i++) { |
25 if ( input[i] == true ) { | |
1248 | 26 printf("%ld\n",i); |
1171 | 27 } |
28 } | |
29 return 0; | |
30 } |