Блог пользователя Licheng

Автор Licheng, 15 лет назад, По-английски
#include <stdio.h>
int main()
{
printf("Hello codeforces!");
}
  • Проголосовать: нравится
  • -18
  • Проголосовать: не нравится

15 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +14 Проголосовать: не нравится

#include <stdio.h>
int main()
{
printf("/*what do you expect of this?*/",
printf("!!!"),
printf("original"),
printf("more "),
printf("be "),
printf("to "),
printf("try ")
); // end printf

return 0; // never forget this if you are doing sport programming in C/C++
} // main
15 лет назад, скрыть # |
 
Проголосовать: нравится -8 Проголосовать: не нравится
may be adding return 0; would be good in future. All the best.
:)
  • 15 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится
    From Wikipedia:
    Within functions that define a non-void return type, failure to return a value before control reaches the end of the function results in undefined behaviour (compilers typically provide the means to issue a diagnostic in such a case).[17] The sole exception to this rule is the main function, which implicitly returns a value of zero.[18]
    • 15 лет назад, скрыть # ^ |
      ← Rev. 2  
      Проголосовать: нравится +3 Проголосовать: не нравится

      Hm... Wikipedia... Is it a new compiler?

      A lot of contestants during last 15 years have a lot of trouble because of omission of this ending return. Surely one could enjoy spending his time during contest and found out how present compiler reacts.

      But I suppose that such experiments are not real goal for contestants.

      There are specific compilers + library suits which does not even allow main to have "int" type (like Keil or WinAVR), but that means nothing.
      • 15 лет назад, скрыть # ^ |
        ← Rev. 2  
        Проголосовать: нравится +2 Проголосовать: не нравится

        Quote has a link to standard of language c++. It's a compiler's problem, if it doesn't follow standards.
        • 15 лет назад, скрыть # ^ |
           
          Проголосовать: нравится 0 Проголосовать: не нравится
          Compiler's problem would become contestant's problem if he want to rely upon some "standard" but obscure facts, without significant reason to do so. I believe that MSVC and G++ would work well, and none would use Borland. But I do not see what for we need to skip these few characters if it is altogether proper and meaningful that int function should return int value.
15 лет назад, скрыть # |
 
Проголосовать: нравится -8 Проголосовать: не нравится
Hello, codeforces! - is rigth
15 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится
Adding \n at the end of the message would also be a better practice I think...