c語言 譚浩強第五版第五章習題第17題 桌球比賽

2021-10-04 12:58:25 字數 485 閱讀 2307

#include

#include

intmain()

else

//c語言要跳出所有迴圈,可以使用goto語句。

//在所有迴圈外,定義乙個標識,通過goto語句直達該標識,起到跳出所有迴圈的作用。

}}exit_all_loop:

//exit_all_loop:跳出迴圈後所要執行的語句

system

("pause");

return0;

}

本題一共有六組資料,最後只輸出了三組,歸功於goto語句,如果可以它能夠跳出所有的語句,當然也包括兩重迴圈。(break只能終止一重迴圈)

while(1)

}exit_all_loop:

//跳出迴圈後需要執行的語句

《C程式設計(第五版)》譚浩強編著 習題 第五章

include include intmain 最大公約數 for i a i 1 i 最小公倍數 for j b j a b j printf 最大公約數為 d n maxdivisor printf 最小公倍數為 d n 英文本母個數為 d n letter printf 空格個數為 d n s...

c primer 第五版課後習題 第五章

第五章主要講了函式 include include include include using namespace std void test 5 9 std cout 母音字母個數為 t cnt endl void test 5 10 std cout 母音字母a的個數為 t cnt a endl...

C Primer第五版 第五章 程式設計題

5.9 編寫一段程式,使用一系列if語句統計從cin讀入的文字中有多少母音字母。include void main std cout a acnt std endl std cout e ecnt std endl std cout i icnt std endl std cout o ocnt s...