0
我很新的C++, 在這個程序結束時,我希望它跳回一個較早的子函數,允許用戶在稍後的子函數中提供新的輸出之前輸入新的值。 目前它將成功返回到所需的子功能。然而程序退出後,而不是繼續下一個子功能。更改子函數C++
這裏是int main;
int main()
{
welcome();
input_dimensions();
input_loading();
transition();
twodarray();
initial_calculations();
bending_stress();
shearing_stress();
bearing_stress();
conclusion();
cin.get();
cin.get();
return 0;
}
和繼承人的最後一個子功能
// C O N C L U S I O N
void conclusion()
{
// End Results
cout << "\n\n\n____________ C O N C L U S I O N_____________ \n\n" << endl;
if ((bendingstress < designbending) && (shearstress < designshear) && (( bearingstress <= (designbearing * kc90))))
{
cout << "Beam is adequate for the input loads \n\n\n" << endl;
cout << "\n\n\nPlease scroll up for more information \n\n\n" <<endl;
cout << "\nPlease press ENTER to design a new beam or close this screen to quit" <<endl;
system ("pause > nul");
system ("CLS");
return input_dimensions();
}
else
{
cout << "\n\n W A R N I N G\n THIS BEAM IS AT RISK OF FAILURE ! \n" << endl;
cout << "\nPlease scroll up for more information before trying new values \n" <<endl;
cout << "\nOnce ready, please press ENTER to try new beam member properties \n" <<endl;
system ("pause > nul");
system ("CLS");
return input_dimensions();
}
}
謝謝您的時間
閱讀有關循環。 – jwodder
另外,在繼續之前,'system(「pause」)'是一個等待按鍵的非常不方便的方法。 'getch'&'getche'是更好的選擇。 – enhzflep
謝謝@enhzflep – CHARLIE