Вроде поиск на RSDN-е результатов не дал (хотя тема 2002 года). Скажите, если баян.
What is the output of the following program on a standards-conforming C++ compiler?
#include <iostream>
#include <iomanip>
int main()
{
int x = 1;
for( int i = 0; i < 100; ++i );
// What will the next line do? Increment???????????/
++x;
std::cout << x << std::endl;
return 0;
}
Невозможное мы сделаем сегодня — чудо займет немного больше времени. /Аноним/
Здравствуйте, UnrealAlex, Вы писали:
UA>Вроде поиск на RSDN-е результатов не дал (хотя тема 2002 года). Скажите, если баян.
UA>What is the output of the following program on a standards-conforming C++ compiler?
UA>
UA>#include <iostream>
UA>#include <iomanip>
UA>int main()
UA>{
UA> int x = 1;
UA> for( int i = 0; i < 100; ++i );
UA> // What will the next line do? Increment???????????/
UA> ++x;
UA> std::cout << x << std::endl;
UA> return 0;
UA>}
UA>
UA>
Это не вопрос на знание С++, а тест на зрение
Я, к примеру, эту точку с запятой заметил только после ответа Другого Анонима...
Здравствуйте, UnrealAlex, Вы писали:
UA>Здравствуйте, Другой Аноним, Вы писали:
ДА>Здравствуйте, UnrealAlex, Вы писали:
ДА>Ну "2" он должен напечатать. А в чем вопрос? UA>А теперь проверь
Здравствуйте, Ed.ward, Вы писали:
EW>Здравствуйте, UnrealAlex, Вы писали:
UA>>Здравствуйте, Другой Аноним, Вы писали:
ДА>>Здравствуйте, UnrealAlex, Вы писали:
ДА>>Ну "2" он должен напечатать. А в чем вопрос? UA>>А теперь проверь
EW>Ха ха, там еще и слешик после коментария стоит
EW>Окулистам этот тест, однозначно...
EW>Ed.ward
да, действительно, там стоит "??/", что эквивалентно "\" — переносу
З.Ы.
мне просто очень понравилось — решил поделиться
Здравствуйте, Ed.ward, Вы писали:
EW>Здравствуйте, UnrealAlex, Вы писали:
UA>>Здравствуйте, Другой Аноним, Вы писали:
ДА>>Здравствуйте, UnrealAlex, Вы писали:
ДА>>Ну "2" он должен напечатать. А в чем вопрос? UA>>А теперь проверь
EW>Ха ха, там еще и слешик после коментария стоит
EW>Окулистам этот тест, однозначно...
EW>Ed.ward
Здравствуйте, Octane, Вы писали:
O>Здравствуйте, Ed.ward, Вы писали:
EW>>Здравствуйте, UnrealAlex, Вы писали:
UA>>>Здравствуйте, Другой Аноним, Вы писали:
ДА>>>Здравствуйте, UnrealAlex, Вы писали:
ДА>>>Ну "2" он должен напечатать. А в чем вопрос? UA>>>А теперь проверь
EW>>Ха ха, там еще и слешик после коментария стоит
EW>>Окулистам этот тест, однозначно...
EW>>Ed.ward
O> плз объясните почему 1 а не 2 Объяснения тут — Re[4]: задачка: What is the output
Здравствуйте, Octane, Вы писали:
O> плз объясните почему 1 а не 2
Compiler Warning (level 3) C4010
single-line comment contains line-continuation character
A single-line comment (introduced by //) contains a line-continuation character (\). The next line after the line-continuation character is ignored; it is considered to be the continuation of the previous line and is treated as a comment.
For performance reasons, some syntax-directed editors will not correctly indicate the physical line following the line-continuation character as a comment. You should ignore the syntax coloring on any lines that cause this warning.
Здравствуйте, Ярослав Александрович, Вы писали:
ЯА>
ЯА>Compiler Warning (level 3) C4010
ЯА>single-line comment contains line-continuation character
ЯА>For performance reasons, some syntax-directed editors will not correctly indicate the physical line following the line-continuation character as a comment. You should ignore the syntax coloring on any lines that cause this warning.
а можно ли как-нибудь заставить студию красить эту строчку цветом комментов?
Problem
Guru Questions
Answer the following questions without using a compiler.
1. What is the output of the following program on a standards-conforming C++ compiler?
#include <iostream>
#include <iomanip>
int main()
{
int x = 1;
for( int i = 0; i < 100; ++i );
// What will the next line do? Increment???????????/
++x;
std::cout << x << std::endl;
}
2. How many distinct errors should be reported when compiling the following code on a conforming C++ compiler?
struct X {
static bool f( int* p )
{
return p && 0[p] and not p[1:>>p[2];
};
};
Здравствуйте, Ярослав Александрович, Вы писали:
ЯА>For performance reasons, some syntax-directed editors will not correctly indicate the physical line following the line-continuation character as a comment. You should ignore the syntax coloring on any lines that cause this warning. ЯА>[/q]
У меня дру как-то рисовал в комментсах ASCII графику для объяснения кода и так случилось что в последне строке комментариев бы обратный слэш, и студия не комментила следующую строку...
как он парился искал эту багу...