看板 NTUBIME-100 關於我們 聯絡資訊
舉個例子,讓大家了解如何用其他結構來取代 goto 這個語法 假設大家只看懂 if 和 while 兩種語法 : int check = 1; //--- if check = 1 → wanna check again, else quit the program. int question_num = 0; while( check == 1 ) { // = = = Question A = = = if( question_num == 0 ){ //--- put your question here. }else if( question_num == 1 ){ //--- re-answer the question. } // = = = Question B = = = if( question_num == 0 ){ //--- bla ~ }else if( question_num == 2 ){ //--- ba ba ba ~ } // = = = wanna check ? = = = cin>> question_num; //--- input the question number u wanna check. if( question_num != 0 ){ check = 1; }else{ check = 0; } } //~~~ END ~~~ 花點時間,弄懂上面的程式結構流程,相信會有所幫助的 大家多多討論吧 GO GO GO -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.94.109