I-is my code good enough anon?#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
/*Here starts the code :3*/
bool is_sorted(int *a, int n) /* Checks if the list is sorted ^_^ */
{
while ( --n >= 1 ) {
if ( a[n] < a[n-1] ) return false;
}
return true;
}
void shuffle(int *a, int n) /*Shuffles the list because it's fun :-D*/
{
int i, t, r;
for(i=0; i < n; i++) {
t = a[i];
r = rand() % n;
a[i] = a[r];
a[r] = t;
}
}
void sort(int *a, int n) /*<---This is the sorting function you'll know because it is named "sort" *_* */
{
while ( !is_sorted(a, n) ) shuffle(a, n);
}
int main() /*Main program where the fun starts!! :DDD*/
{
int numbers[] = { 1, 10, 9, 7, 3, 0 };
int i;
sort(numbers, 6);
for (i=0; i < 6; i++) printf("%d ", numbers[i]);
printf("\n");
}
/*Here ends the code :3 Remember to check my last github commit about changing master/slave definitions */
dumb 2d poster
>>62088941
But why? Pepe-kun? Did I do something wrong?
Didn't even bother to read after seeing the shitty >Look at me I put emotes in my comments
comments.
>>62088991
Shit
>>62088915
>line over 100 characters long
>>62088991
I thought it was cool :_(
>>62088915
Needs more anime
>linear minimal runtime
I would say that code is optimal
>>62088915
....yeah, remove emoticons pls.
>>62088915
Not my style but ok.
The NP algorithm for sorting is crazy though.
>>62088915
Cute anime girls wouldn't care about the master/slave definitions. Only SJWs care about that.
nice koding op
I think op did a good job keep up the good work
>>62088915
cute code!
is this the anime code thread?
Gotta love exponential time algorithms. It's been stuck on length 15 for quite a while.#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define ARRAYSZ 256
/*Here starts the code :3*/
bool is_sorted(int *a, int n) /* Checks if the list is sorted ^_^ */
{
while ( --n >= 1 ) {
if ( a[n] < a[n-1] ) return false;
}
return true;
}
void shuffle(int *a, int n) /*Shuffles the list because it's fun :-D*/
{
int i, t, r;
for(i=0; i < n; i++) {
t = a[i];
r = rand() % n;
a[i] = a[r];
a[r] = t;
}
}
void sort(int *a, int n) /*<---This is the sorting function you'll know because it is named "sort" *_* */
{
while ( !is_sorted(a, n) ) shuffle(a, n);
}
int main(int argc, char **argv) /*Main program where the fun starts!! :DDD*/
{
unsigned int n;
int i;
if (argc > 1 && (n = atoi(argv[1])));
else n = ARRAYSZ;
int numbers[n];
for (i = 0; i < n; ++i) {
numbers[i] = rand();
// printf("%d ", numbers[i]);
}
// putchar('\n');
sort(numbers, n);
for (i=0; i < n; i++) printf("%d ", numbers[i]);
putchar('\n');
return 0;
}
/*Here ends the code :3 Remember to check my last github commit about changing master/slave definitions */
>>62092115
It's super exponential. Bogosort has an average runtime complexity of n!, and n! grows faster than any exponential.
>>62091700
It's some sort of BASIC, definitely not C
I want a cute coder bf already
>>62094560
How can I contact you? GNU/Social?
>>62088915
So basically, you made a shitty bogosort program.
>>62088941
dumb frog poster
>>62089030
you overdid it (a lot)>>62089030
w-what does /g/-chan t-think of my code onegai33o<CR>Fizz<CR><Esc>qqABuzz<Esc>5kq19@q:%s/^$/\=line('.')<CR>
>>62088941
pepe is 2d baka
>>62095515
kawaii! demo... yoku wakaranai
>>62095658
a-arigato
Vim fizzbuzz regex desu
>>62095719
regex janai yo
macro dayo
It's not good until you put on knee socks and sit on my lap anon chan.
>>62095986
Will you pet me if I do a good job?
>>62096018
I'll give you a lollipop.
>>62088915
Cute code
>>62096054
I love sweets!
>>62096083
Thats good, I have enough to give you a stomach full.
>>62088915
Klossy/10, remove yourself from the genepool