對不起,這個問題,但我沒有其他地方去了,它讓我覺得我找不到解決方案。我對編程語言Pascal非常好,所以這個C語言對我來說似乎很熟悉,但添加一個if函數來改變while循環的整個結構對我來說太複雜了。請任何幫助表示讚賞。嗨,有人可以幫助我的這個循環
The array variable consists of a sequence of ten numbers. Inside the while loop, you must write two if conditions, which change the flow of the loop in the following manner (without changing the printf command):
- If the current number which is about to be printed is less than 5, don't print it.
- If the current number which is about to be printed is greater than 10, don't print it and stop the loop.
Notice that if you do not advance the iterator variable i and use the continue derivative, you will get stuck in an infinite loop.
#include <stdio.h>
int main()
{
int array[] = {1, 7, 4, 5, 9, 3, 5, 11, 6, 3, 4};
int i = 0;
while (i < 10)
{
/* your code goes here */
printf("%d\n", array[i]);
i++;
}
return 0;
}
爲什麼Java,C++和Pascal標籤? –
您是否熟悉'continue'和'break'? –
如果你熟悉C語言,你肯定熟悉'if'和'break'嗎? –