r/badcode • • Jun 04 '19

[deleted by user]

[removed]

24 Upvotes

41 comments sorted by

View all comments

3

u/UnrelatedString Jun 05 '19 edited Jun 05 '19

Another submission, in C++ this time:

#include <iostream>
/* If using using namespace std is bad then surely this is ideal? */
namespace cplusplus_standard_template_library = std;
#define STRING cplusplus_standard_template_library::string
#include <string>
namespace high_and_low {
    STRING high_and_low(STRING) ;
}
#include <cstdio>
#include <cstdlib>
#include <forward_list>
STRING high_and_low::high_and_low(STRING numbers_list) {
    numbers_list.push_back(**&",&**");
#define DECLARE_NUMBER(S,V) S##signed long long int V;
    DECLARE_NUMBER(,the_number)
    DECLARE_NUMBER(un,number)
    DECLARE_NUMBER(un,num)
    DECLARE_NUMBER(,* list_of_numbers)
    DECLARE_NUMBER(un,numbers)
    num = 1ll^1ll;
    numbers = num;
#define ALLOC(H) *) cplusplus_standard_template_library:: H##alloc(
#define L sizeof(signed long long int)
    list_of_numbers = (long long int ALLOC(m) 0*L);
    while (
	    cplusplus_standard_template_library::sscanf(
		    numbers_list.c_str()+num,"%lld,%lln",&the_number,&number))
	    {
		    num += number;
		    numbers++;
		    list_of_numbers = (long long int ALLOC(re) list_of_numbers, numbers*L);
		    list_of_numbers[~-numbers] = the_number;
	}cplusplus_standard_template_library::forward_list<
    DECLARE_NUMBER(, > list)
    while (numbers--)
	    list.emplace_front(*list_of_numbers++);
    bool is_it = num;
#define ITERATE(V) for( signed long long int const& V : list) {
    ITERATE(w) ITERATE(x)
	    is_it xor_eq is_it;
	    ITERATE(y) ITERATE(z)
		    switch ((w>=y)&(x<=z)) {
			    default:
			    is_it = 1;
			    case 2:
			    case 1:
			    is_it and_eq 1;
			    break;
		    }}}
	    if(is_it);
	    else {
		    STRING digits;
#define DECOM(V) DECLARE_NUMBER(, new_##V )\
new_##V = V <0?- V : V ;while( new_##V ){digits.push_back(( new_##V %10)\
+060); new_##V /=10;}
		    if (x < 0)
			    digits.push_back(*"-_-");
		    DECOM(x)
		    digits.push_back(054);
		    digits.push_back(040);
		    if (w < 0)
			    digits.push_back(*"-_-");
		    DECOM(w)
		    return digits;
	    }}}
	    return "stfu Xcode";
}

ideone link: https://ideone.com/D6Najv

0

u/[deleted] Jun 05 '19

[deleted] — view deleted comment

2

u/UnrelatedString Jun 05 '19

Ah, I’ll fix that now, thanks for reminding me

1

u/UnrelatedString Jun 05 '19

Doing it on mobile probably messed it up a bit but for this that’s probably a good thing