Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

goto is good

Name: Anonymous 2012-06-11 22:02

if you think otherwise you're a trendfag. goto is far more efficient than function calls for short blocks of code (lol compiler ignoring inline) and have a lot of neat applications.

Name: Anonymous 2012-06-12 16:00

>>40
yes it does, but can you do it without checking for "FizzBuzz" explicitly? also without a helper variable?

Name: Anonymous 2012-06-12 16:18

void fizzbuzz(int end){
    int i;
    for(i = 3; i < end; i += 3)
        printf("Fizz\n");
    for(i = 5; i < end; i += 5)
        if(i % 3)
            printf("Buzz\n");
        else
            printf("FizzBuzz\n");
}


if order is not important

Name: Anonymous 2012-06-12 16:24

>>42
that is actually wrong, forgive me /prague/

void fizzbuzz(int end){
    end /= 15:
    while(end--)
        printf("Fizz\nBuzz\nFizz\nFizz\nBuzz\nFizz\nFizzbuzz\n");
}

Name: Anonymous 2012-06-12 16:38

>>43
That's also wrong because you're supposed to print the number for ones that aren't fizz/buzz/fizzbuzz, e.g.
1
2
fizz
4
buzz
etc.

Name: Anonymous 2012-06-12 16:51

>>44
oh right
static char * arr[] = {"%d", "%d", "Fizz", "%d", "Buzz", "Fizz", "%d", "%d", "Fizz", "Buzz", "%d", "Fizz", "%d", "%d", "FizzBuzz"};
int fizbuzz(int end){
int i;
for(i = 0; i < end; ++i)
printf(arr[i%15], i);
}

Name: Anonymous 2012-06-12 21:51

void fizzbuzz(size_t upto)
{
    char *text[] = {"FizzBuzz\n","%d\n","%d\n","Fizz\n","%d\n","Buzz\n","Fizz\n","%d\n","%d\n","Fizz\n","Buzz\n","%d\n","Fizz\n","%d\n","%d\n"};

    for(size_t i = 0; i < upto; ++i)    printf(text[i%15], i);
}

hai gaiz cna i play wit u?

Name: Anonymous 2012-06-12 22:39

thinks using gotos for simple control flow is faster than using built in syntax for equivalent control flow

there are times to use goto, but this is not one of them. I love the art of goto programming as much as anyone, but don't act like any of this is actually useful for anything other than fun.

Name: Anonymous 2012-06-12 22:54

>>47
equivalent

Name: Anonymous 2012-06-12 23:01

I have nothing against goto, but "efficiency" is the worst possible reason to use it.

Name: Anonymous 2012-06-12 23:19

>>48
there is a transformation. while is all you need for any control flow, although extra variables may need to be introduced. tail calls and if can be trivially compiled to a convoluted bundle of gotos, with no additional resources as well. Any arbitrary block of goto code can be translated to a set of functions that transfer control to one another with tail calls.

Name: Anonymous 2012-06-13 0:13

>>17,20

Lambda Calculus.

int is_even(int n)
{
    return !(n & 1);
}

Name: Anonymous 2012-06-14 3:45

congrats op, your  thread is at the very bottom of the board.

how does it feel, retard?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List