/**************************************************** * Falcon DISPLAY ROW * DESCRIPTION: Displays a single row on the Falcon ****************************************************/ void Falcon_displayRow(struct Falcon* Falcon, char clear, char row) { if (clear == 1) { printf_clearBanks(Falcon -> xLocation, Falcon -> yLocation, SHIP_LENGTH); printf_clearBanks(Falcon -> xLocation, Falcon -> yLocation + 1, SHIP_LENGTH); printf_clearBanks(Falcon -> xLocation, Falcon -> yLocation + 2, SHIP_LENGTH); } else if (row == 0) { if (Falcon -> direction == 0) { set_LCD_Cursor(Falcon -> xLocation, Falcon -> yLocation); printf_array(Falcon -> top_row, SHIP_LENGTH); } else { set_LCD_Cursor(Falcon -> xLocation, Falcon -> yLocation); printf_array_reverse(Falcon -> top_row, SHIP_LENGTH); } } else if (row == 1) { if (Falcon -> yLocation + 1 < 6) { if (Falcon -> direction == 0) { set_LCD_Cursor(Falcon -> xLocation, Falcon -> yLocation + 1); printf_array(Falcon -> mid_row, SHIP_LENGTH); } else { set_LCD_Cursor(Falcon -> xLocation, Falcon -> yLocation + 1); printf_array_reverse(Falcon -> mid_row, SHIP_LENGTH); } } } else { if (Falcon -> yLocation + 2 < 6) { if (Falcon -> direction == 0) { set_LCD_Cursor(Falcon -> xLocation, Falcon -> yLocation + 2); printf_array(Falcon -> bot_row, SHIP_LENGTH); } else { set_LCD_Cursor(Falcon -> xLocation, Falcon -> yLocation + 2); printf_array_reverse(Falcon -> bot_row, SHIP_LENGTH); } } } }
int main(int argc, const char *argv[]) { int array[M][N]; int *ptr = &array[0][0]; init_array(ptr , M*N); printf_array(ptr , M*N); getchar(); sort_array(ptr , 0 ,M*N-1); printf_array(ptr , M*N); return 0; }
int main(int argc, const char *argv[]) { int array[M]; init_array(array , M); printf_array(array , M); delete_same_data(array , M); printf_array(array , M); printf("\n"); printf_result(array , M); return 0; }
int main(void) { int array[N]; init_array(array,N); printf("original\n"); printf_array(array,N); getchar(); // bubble_array(array,N); quick_sort(array,0,N-1); printf("sort\n"); printf_array(array,N); return 0; }
int main() { printf_array(data, array_size); system("pause"); return 0; }
/********************************************************* * DISPLAY ROW *********************************************************/ void displayRow(struct Jet* input, char clear, char row) { if (clear == 1) { printf_clearBanks(input -> xLocation, input -> yLocation, JET_LENGTH); printf_clearBanks(input -> xLocation, input -> yLocation + 1, JET_LENGTH); printf_clearBanks(input -> xLocation, input -> yLocation + 2, JET_LENGTH); } else if (input -> direction == 0) { if (row == 0) { set_LCD_Cursor(input -> xLocation, input -> yLocation); printf_array(input -> top_row, JET_LENGTH); } else if (row == 1) { set_LCD_Cursor(input -> xLocation, input -> yLocation + 1); printf_array(input -> mid_row, JET_LENGTH); } else { set_LCD_Cursor(input -> xLocation, input -> yLocation + 2); printf_array(input -> bot_row, JET_LENGTH); } } else { if (row == 0) { set_LCD_Cursor(input -> xLocation, input -> yLocation); printf_array_reverse(input -> top_row, JET_LENGTH); } else if (row == 1) { set_LCD_Cursor(input -> xLocation, input -> yLocation + 1); printf_array_reverse(input -> mid_row, JET_LENGTH); } else { set_LCD_Cursor(input -> xLocation, input -> yLocation + 2); printf_array_reverse(input -> bot_row, JET_LENGTH); } } }
int main(){ // /* int m; m=getch(); while(m){ m=getch(); printf("%d\n",m); }*/ int temp=0, i,j;//以下所有代码,I表示行,j表示列 /*获取控制台光标,并隐藏*/ CONSOLE_CURSOR_INFO cci; HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); COORD coord; system("color 5F");//改变控制台窗口背景色和文字颜色 system("mode con cols=30 lines=11");//定义控制台窗口大小 randDete(); randDete(); cci.bVisible = FALSE;//隐藏输入光标 cci.dwSize = sizeof(cci); SetConsoleCursorInfo(handle, &cci); printf_array(); /*游戏主要消息循环*/ while(1){ temp=getch();//等待用户按下键操作 system("cls"); printf_array(); is_moved=0; /*判断输入是或否合法*/ if(temp!=UP&&temp!=DOWN&&temp!=LEFT&&temp!=RIGHT&&temp!=ESC) //printf_array(); continue; else{ /*方向键主要操作*/ if(temp==RIGHT){ right_move(); if(is_moved==1){ randDete(); } printf_array(); printf("\n"); } if(temp==DOWN){ down_move(); if(is_moved==1){ randDete(); } printf_array(); printf("\n"); } if(temp==LEFT){ left_move(); if(is_moved==1){ randDete(); } printf_array(); printf("\n"); } if(temp==UP){ up_move(); if(is_moved==1){ randDete(); } printf_array(); printf("\n"); } /*使用ESC键重置游戏*/ if(temp==ESC){ for (i=0;i<4;i++) { for (j=0;j<4;j++) { array[i][j]=0; } } randDete(); randDete(); printf_array(); printf("\n"); } } } return 0; }
/** * \brief Network state event handler. * \param event show network start response or current network state. * * - ARM_NWK_BOOTSTRAP_READY: Save NVK peristant data to NVM and Net role * - ARM_NWK_NWK_SCAN_FAIL: Link Layer Active Scan Fail, Stack is Already at Idle state * - ARM_NWK_IP_ADDRESS_ALLOCATION_FAIL: No ND Router at current Channel Stack is Already at Idle state * - ARM_NWK_NWK_CONNECTION_DOWN: Connection to Access point is lost wait for Scan Result * - ARM_NWK_NWK_PARENT_POLL_FAIL: Host should run net start without any PAN-id filter and all channels * - ARM_NWK_AUHTENTICATION_FAIL: Pana Authentication fail, Stack is Already at Idle state */ void app_parse_network_event(arm_event_s *event ) { arm_nwk_interface_status_type_e status = (arm_nwk_interface_status_type_e)event->event_data; switch (status) { case ARM_NWK_BOOTSTRAP_READY: /* Network is ready and node is connect to Access Point */ if(access_point_status==0) { uint8_t temp_ipv6[16]; tr_debug("Network Connection Ready"); access_point_status=1; if( arm_nwk_nd_address_read(net_rf_id,&app_nd_address_info) != 0) { tr_debug("ND Address read fail"); } else { debug("ND Access Point:"); printf_ipv6_address(app_nd_address_info.border_router); debug("ND Prefix 64:"); printf_array(app_nd_address_info.prefix, 8); if(arm_net_address_get(net_rf_id,ADDR_IPV6_GP,temp_ipv6) == 0) { debug("GP IPv6:"); printf_ipv6_address(temp_ipv6); } } if( arm_nwk_mac_address_read(net_rf_id,&app_link_address_info) != 0) { tr_debug("MAC Address read fail\n"); } else { uint8_t temp[2]; debug("MAC 16-bit:"); common_write_16_bit(app_link_address_info.PANId,temp); debug("PAN ID:"); printf_array(temp, 2); debug("MAC 64-bit:"); printf_array(app_link_address_info.mac_long, 8); debug("IID (Based on MAC 64-bit address):"); printf_array(app_link_address_info.iid_eui64, 8); } } break; case ARM_NWK_NWK_SCAN_FAIL: /* Link Layer Active Scan Fail, Stack is Already at Idle state */ tr_debug("Link Layer Scan Fail: No Beacons"); access_point_status=0; break; case ARM_NWK_IP_ADDRESS_ALLOCATION_FAIL: /* No ND Router at current Channel Stack is Already at Idle state */ tr_debug("ND Scan/ GP REG fail"); access_point_status=0; break; case ARM_NWK_NWK_CONNECTION_DOWN: /* Connection to Access point is lost wait for Scan Result */ tr_debug("ND/RPL scan new network"); access_point_status=0; break; case ARM_NWK_NWK_PARENT_POLL_FAIL: access_point_status=0; break; case ARM_NWK_AUHTENTICATION_FAIL: tr_debug("Network authentication fail"); access_point_status=0; break; default: debug_hex(status); debug("Unknow event"); break; } if(access_point_status == 0) { //Set Timer for new network scan eventOS_event_timer_request(1, ARM_LIB_SYSTEM_TIMER_EVENT,node_main_tasklet_id,5000); // 5 sec timer started } }