Я считаю, что лучший способ - это использовать gdata youTube, а затем получить информацию из XML, который возвращается
http://gdata.youtube.com/feeds/api/videos/6_Ukfpsb8RI
Обновление: теперь есть более новый API, который вы должны использовать вместо этого
https://developers.google.com/youtube/v3/getting-started
URL: https://www.googleapis.com/youtube/v3/videos?id=7lCDEYXw3mM&key=YOUR_API_KEY
&fields=items(id,snippet(channelId,title,categoryId),statistics)&part=snippet,statistics
Description: This example modifies the fields parameter from example 3 so that in the API response, each video resource's snippet object only includes the channelId, title, and categoryId properties.
API response:
{
"videos": [
{
"id": "7lCDEYXw3mM",
"snippet": {
"channelId": "UC_x5XG1OV2P6uZZ5FSM9Ttw",
"title": "Google I/O 101: Q&A On Using Google APIs",
"categoryId": "28"
},
"statistics": {
"viewCount": "3057",
"likeCount": "25",
"dislikeCount": "0",
"favoriteCount": "17",
"commentCount": "12"
}
}
]
}
Это потому, что операторы while допустимы в пределах do- Цикл while.
Рассмотрим различные варианты поведения, если точка с запятой не требовалась:
int x = 10;
int y = 10;
do
while(x > 0)
x--;
while(x = y--);
Потому что вы заканчиваете утверждение. Оператор заканчивается либо блоком (разделенным фигурными скобками), либо точкой с запятой. «делать это, пока это» является единственным оператором и не может заканчиваться блоком (потому что он заканчивается на «пока»), поэтому ему нужна точка с запятой, как и любому другому оператору.
Хотя я не знаю ответа, последовательность кажется лучшим аргументом. Каждая группа операторов в C / C ++ либо заканчивается
Зачем создавать конструкцию, которая не выполняет ни то, ни другое?
C заканчивается точкой с запятой (тогда как Паскаль разделяется точкой с запятой). Было бы непоследовательно оставлять там точку с запятой.
Я, честно говоря, ненавижу повторное использование while для цикла do. Думаю, повторять - пока было бы меньше путаницы. Но это то, что есть.
В C / C ++ пробелы не влияют на структуру (например, в Python). В операторах C / C ++ должен завершаться точкой с запятой . Это разрешено:
do
{
some stuff; more stuff; even more stuff;
}
while(test);
If you take a look at C++ grammar, you'll see that the iteration statements are defined as
while ( condition ) statement
for ( for-init-statement condition-opt ; expression-opt ) statement
do statement while ( expression ) ;
Note that only do-while
statement has an ;
at the end. So, the question is why the do-while
is so different from the rest that it needs that extra ;
.
Let's take a closer look: both for
and regular while
end with a statement. But do-while
ends with a controlling expression enclosed in ()
. The presence of that enclosing ()
already allows the compiler to unambiguously find the end of the controlling expression: the outer closing )
designates where the expression ends and, therefore, where the entire do-while
statement ends. In other words, the terminating ;
is indeed redundant.
However, in practice that would mean that, for example, the following code
do
{
/* whatever */
} while (i + 2) * j > 0;
while valid from the grammar point of view, would really be parsed as
do
{
/* whatever */
} while (i + 2)
*j > 0;
This is formally sound, but it is not really intuitive. I'd guess that for such reasons it was decided to add a more explicit terminator to the do-while
statement - a semicolon. Of course, per @Joe White's answer there are also considerations of plain and simple consistency: all ordinary (non-compound) statements in C end with a ;
.