less_retarded_wiki/cpp.md
2024-12-07 19:46:32 +01:00

1.7 KiB

C++

C++ (also C卐卐 or crippled C) is an object-obsessed joke language based on C to which it adds only capitalist features and bloat, most notably object obsession. Most good programmers such as Richard Stallman and Linus Torvalds agree that C++ is hilariously messy and also tragic in that it actually succeeded to become mainstream. The language creator Bjarne Stroustrup himself infamously admitted the language sucks but laughs at its critics because it became successful anyway -- indeed, in a retarded society only shit can succeed. As someone once said, "C++ is not an increment, it is excrement". C++ specification has over 2000 pages :D

C++ source code files have the extensions .cpp or .cc (for "crippled C").

Examples

Here is our standardized divisor tree program in C++:

#include <iostream> // include standard I/O library
using namespace std;

// recursive function, prints divisor tree of x
void printDivisorTree(unsigned int x)
{
  int a = -1, b = -1;
 
  for (unsigned int i = 2; i <= x / 2; ++i) // find two closest divisors
    if (x % i == 0)
    {
      a = i;
      b = x / i;

      if (b <= a)
        break;
    }

  cout << '(';

  if (a > 1)
  {
    printDivisorTree(a);
    cout << ' ' << x << ' ';
    printDivisorTree(b);
  }
  else
    cout << x;

  cout << ')';
}

int main()
{
  while (1) // main loop, read numbers from the user
  {
    unsigned int number;
    cout << "enter a number: " << flush;
    cin >> number;

    if (!cin.fail() && number < 1000)
    {
      printDivisorTree(number);
      cout << endl;
    }
    else
      break;
  }

  return 0;
}