int selection(void) { int no = 0; do{ no = inputNo(); switch(no){ case 1: enter(); break; case 2: list(); break; case 3: serch(); break; case 4: printf("【終了】\n"); break; default: printf("1~4までの半角数字でご入力頂きますよう、お願いします。\n"); break; } }while(4 != no); return 0; }
///* int main(){ //第3回試走会用 int ball_count = 0; bool area_flag = OFF; float serch_posi = 0.0; float move_dis = 0.0; state = init_state; // color = RED; while(1){ //while開始 switch(state){ case init_state: initialize(); state = free_ball; //state = ball_search; //state = finish; break; case free_ball: Line_Trace(3); turn(85.0, FAST); wait(0.25); servo_throw(); wait(0.25); servo_ini(); wait(0.25); turn(-85.0,FAST); Line_Trace(2); state = ball_search; break; case ball_search: if(move_flag){ while(l_Y <= move_dis) Line_Trace(); stop(); move_flag = OFF; } else{ if(color != NO_BALL){ while(l_Y <= serch_posi) Line_Trace(); stop(); } } serch(); state = ball_shoot; //if((l_time+35) > LIMIT) // state = finish; break; case ball_shoot: wait(0.25); //color = what_color(); if(color != NO_BALL){ //色を得られたら //turn(180, FAST); //wait(0.25); if(area_flag){ if(color == YELLO) Line_Trace(color); else Line_Trace(color + 1); } else{ if(color == YELLO) Line_Trace(color - 1); else Line_Trace(color); } Ball_Shoot(); ball_count++; if(ball_count == B_GOAL || (l_time+35) > LIMIT){ state = finish; break; } if(color == YELLO) Line_Trace(color - 1); else Line_Trace(color); } //目標まで行ったかの確認 state = ball_search; if(move_flag) state = area_move; break; case area_move: move_dis = 250; if(serch_posi >= 1200 - move_dis) //行き過ぎ防止用 move_dis = 0; serch_posi += move_dis; area_flag = ON; state = ball_search; break; case finish: fine(); break; }//switch終了 }//while終了 }//main終了