公司網(wǎng)站的建設要注意什么臨沂百度推廣的電話
1、continue? 語句
作用:在循環(huán)語句中,跳過本次循環(huán)中余下尚未執(zhí)行的語句。繼續(xù)下一次循環(huán)。
注意:continue只能用于循環(huán)中。
示例:
代碼:
//continue的用法
#include<iostream>
using namespace std;
int main()
{
?? ?//如果是奇數(shù),則輸出,否則不輸出
?? ?for (int i = 1; i <= 100; i++)
?? ?{
?? ??? ?if (i % 2 == 0)
?? ??? ?{
?? ??? ??? ?continue;
?? ??? ?}
?? ??? ?cout << i << endl;
?? ??? ??? ?
?? ?}
?? ?system("pause");
?? ?return 0;
}
注意:continue 并沒有使整個循環(huán)終止,而break會跳出循環(huán)。
2、goto語句
作用:可以無條件跳轉(zhuǎn)語句。
語法:goto? ? ?標記;
注意:一般情況下,我們給標記起名時,一般都大寫。
解釋:如果標記存在,執(zhí)行到goto語句時,會跳轉(zhuǎn)到標記的位置。
示例:
代碼:
//goto語句的使用
#include<iostream>
using namespace std;
int main()
{
?? ?cout << "1.hello" << endl;
?? ?cout << "2.world" << endl;
?? ?goto FLAG;
?? ?cout << "3.girl" << endl;
?? ?cout << "4.boy" << endl;
FLAG:
?? ?cout << "5.hahahaha" << endl;?? ?system("pause");
?? ?return 0;
}
注意:在程序中不建議使用goto語句,以免造成程序流程混亂。