pajenegod's blog

By pajenegod, history, 21 month(s) ago, In English

Take a look at this C++ submission 199864568:

#import <bits/stdc++.h>
using namespace std;
int main()
{
    int a; 
    cin >> a; 
    cout << ((a%2==0 && a>2) ? "YES" : "NO");
}

Don't see it?
Spoilers
  • Vote: I like it
  • +312
  • Vote: I do not like it

»
21 month(s) ago, # |
  Vote: I like it -11 Vote: I do not like it

Haven't seen it. Need to take a look at spoil before.

»
21 month(s) ago, # |
  Vote: I like it +31 Vote: I do not like it

It's well-know trick in codegolf.

  • »
    »
    21 month(s) ago, # ^ |
      Vote: I like it +9 Vote: I do not like it

    That's actually a well-known trick in China.

»
21 month(s) ago, # |
  Vote: I like it +4 Vote: I do not like it

thought it was the missing return 0

»
21 month(s) ago, # |
Rev. 3   Vote: I like it +20 Vote: I do not like it

"one character shorter" is important :D for short-code contests!

»
21 month(s) ago, # |
  Vote: I like it +13 Vote: I do not like it

There's a typo: should be #pragma instead of #prama.

»
21 month(s) ago, # |
  Vote: I like it +10 Vote: I do not like it

Chat GPT's answer to "Why is #import deprecated in C++?"

The #import directive was never actually part of the C++ language specification. Instead, it was a Microsoft-specific extension to the language that allowed developers to include type libraries in their code.

Type libraries are files that describe the interfaces of COM (Component Object Model) objects. The #import directive allowed C++ developers to automatically generate C++ classes that encapsulated the interfaces of COM objects described in a type library.

However, because the #import directive was a non-standard extension to the C++ language, it was not portable to other platforms or compilers. Additionally, the use of COM has decreased in recent years, so there is less need for the #import directive.

As a result, the #import directive has been deprecated by Microsoft in favor of using the more portable #include directive to include header files that define C++ classes and functions.

  • »
    »
    21 month(s) ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    #import is completely different depending on MSVC or GCC. That answer chatGPT gave is about MSVC'S #import, but this blog is about GCC's #import.