changeset 1577:be59aef19a22 draft

a*bを含む単語数を数えるように変更
author Masa <e085726@ie.u-ryukyu.ac.jp>
date Sat, 23 Mar 2013 16:53:19 +0900
parents 33731c160268
children a039ff7b0a45
files example/regex_masa/ppe/Exec.cc example/regex_masa/ppe/Exec.o example/regex_masa/regex
diffstat 3 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/example/regex_masa/ppe/Exec.cc	Fri Mar 22 21:26:00 2013 +0900
+++ b/example/regex_masa/ppe/Exec.cc	Sat Mar 23 16:53:19 2013 +0900
@@ -17,6 +17,7 @@
     int word_num = 0;
     int line_flag = 0;
     int line_num = 0;
+    int word_head_a_flag = 0; 
     int i = 0;
     //b以外が先頭の時、word_num - 1
     head_tail_flag[0] = (i_data[0] != 0x62);
@@ -26,18 +27,25 @@
     //i_data[length - 1] = 0x61;  //分割されたファイルのラストがaのときに固まってしまう
 
     for (; i < length; i++) {
-        if (i_data[i] == 0x61 && i_data[i+1] == 0x62) { //abと文字列が並んでいるとき
+        if (i_data[i] == 0x61) {
+            word_head_a_flag = 1;
+        } else if ((i_data[i] == 0x62) && (word_head_a_flag == 1)){
+
             word_flag = 1;
             line_flag = 1;
+            word_head_a_flag = 2;
         
         } else if (i_data[i] == 0x20) { //空白 
             word_num += word_flag;
             word_flag = 0;
+            word_head_a_flag = 0;
+
         } else if (i_data[i] == 0x0A) { // 改行
             line_num += line_flag;
             word_num += word_flag;
             line_flag = 0;
             word_flag = 0;
+            word_head_a_flag = 0;
         }
     }
 
Binary file example/regex_masa/ppe/Exec.o has changed
Binary file example/regex_masa/regex has changed