int main(int argc, char* argv[]){ string str; while(1){ if(getline(cin, str)==0 || str.empty()){ break; } int* arr = new int[str.size()](); int n = splitStr2IntArray(str, arr); vector<interval> ranges; for(int i=0;i<n/2;++i){ ranges.push_back(interval(arr[2*i], arr[2*i+1])); } vector<interval> res1 = merge(ranges); printf("the merge result is:\n"); displayranges(res1); vector<interval> res2 = wash(ranges); printf("the wash result is:\n"); displayranges(res2); delete[] arr; arr=0; res1.clear(); res2.clear(); ranges.clear(); } return 0; }
int washSend(int dish, int doWash) { struct sembuf buf0; buf0.sem_flg = 0; buf0.sem_num = FULL; buf0.sem_op = -1; //fprintf(stderr, "FULL=%d\n", semctl(semid, FULL, GETVAL, 0)); if(semop(semid, &buf0, 1) < 0) printf("send full error\n"); if(doWash) wash(dish, time[dish]); #ifdef DEBUG printf("sending dish[%d]={%d}...\n", *freeSlot, dish); #endif mymsg buf; buf.mtype = 1; buf.type = dish; if(msgsnd(msqid, (struct msgbuf*) &buf, sizeof(int), 0) < 0) { printf("Can't send message\n"); } #ifdef DEBUG printf("SEND OK!\n"); #endif }
static int do_test (void) { int result = 0; /* Test the functions with constant arguments. */ if (bswap_16 (0x1234) != 0x3412) { puts ("bswap_16 (constant) flunked"); result = 1; } if (bswap_32 (0x12345678) != 0x78563412) { puts ("bswap_32 (constant) flunked"); result = 1; } if (bswap_64 (0x1234567890abcdefULL) != 0xefcdab9078563412ULL) { puts ("bswap_64 (constant) flunked"); result = 1; } /* Test the functions with non-constant arguments. */ if (bswap_16 (wash (0x1234)) != 0x3412) { puts ("bswap_16 (non-constant) flunked"); result = 1; } if (bswap_32 (wash (0x12345678)) != 0x78563412) { puts ("bswap_32 (non-constant) flunked"); result = 1; } if (bswap_64 (wash (0x1234567890abcdefULL)) != 0xefcdab9078563412ULL) { puts ("bswap_64 (non-constant) flunked"); result = 1; } return result; }
static void traverse(htmlNodePtr root) { htmlNodePtr cur_node = root, next_node; int policy; while (cur_node) { next_node = cur_node->next; switch (cur_node->type) { case XML_COMMENT_NODE: cur_node = erase(cur_node); break; case XML_ELEMENT_NODE: policy = decide(cur_node->name); if (policy == STRIP) { // strip code is still buggy, disable for now // fprintf(stderr, "strip %s\n", cur_node->name); next_node = strip(cur_node); cur_node = NULL; } else if (policy == ERASE) { //fprintf(stderr, "erase %s\n", cur_node->name); cur_node = erase(cur_node); } else { wash(cur_node); } break; case XML_TEXT_NODE: break; default: fprintf(stderr, "%d %s \n", cur_node->type, cur_node->name); break; } if (cur_node && cur_node->children) traverse(cur_node->children); cur_node = next_node; } }