Exemple #1
0
int main() {
    long N = 1000000, next;
    
    while ((next = nextFibonacci()) < N)
        printf("%ld\n", next);
        
    return 0;
}
/**
 * @brief Where your program starts running.
 * @param argc How many 'tokens' were typed when you ran the program
 * @param argv A collection of all the tokens that were typed
 * @sideeffect The program is the side effect! CS language is weird...
 * @return This returns 0, unless it crashes or something weird happens.
 *
 * This program has three stages.
 *
 * In the first stage, it figures out the first eight Fibonacci numbers, starting with 1,1,....
 *
 * In the second stage, it figures out the nine Ulam numbers after 5 (which ends up getting redundant after a while...)
 *
 * In the third stage, it counts out the six integers after 1.
 *
 * In the fourth and last stage, it finds the averages of a few trios of numbers.
 */
int main(int argc, char* argv[])
{
	int shaggy_dog;
	int scratchpad2;
	
    printf("Integers...\n");
    nextInteger(1);
    nextInteger(2);
    nextInteger(3);
    nextInteger(4);
    nextInteger(5);
    nextInteger(6);
    printf("\n\n");
   
    printf("Averages...\n");
	//TASK 4: PUT averageOfThree FUNCTION CALLS HERE
    printf("\n\n");
   
    printf("Squares...\n");
    shaggy_dog=0;
    squareOf(        shaggy_dog=nextInteger(shaggy_dog)       );
    squareOf(shaggy_dog=nextInteger(shaggy_dog));
    squareOf(shaggy_dog=nextInteger(shaggy_dog));
    squareOf(shaggy_dog=nextInteger(shaggy_dog));
    squareOf(shaggy_dog=nextInteger(shaggy_dog));
    printf("\n\n");
	
	printf("Fibonacci numbers...\n");
	shaggy_dog=nextFibonacci(1,1);
	scratchpad2=nextFibonacci(shaggy_dog,1);
   
	shaggy_dog=nextFibonacci(shaggy_dog, scratchpad2);
	scratchpad2=nextFibonacci(shaggy_dog, scratchpad2);
	shaggy_dog=nextFibonacci(shaggy_dog, scratchpad2);
	scratchpad2=nextFibonacci(shaggy_dog, scratchpad2);
	shaggy_dog=nextFibonacci(shaggy_dog, scratchpad2);
	scratchpad2=nextFibonacci(shaggy_dog, scratchpad2);
	printf("\n\n");
	
	printf("Ulam numbers...\n");
	shaggy_dog=nextUlam(5);
	scratchpad2=nextUlam(shaggy_dog);
   
	scratchpad2=nextUlam(scratchpad2);
	scratchpad2=nextUlam(scratchpad2);
	scratchpad2=nextUlam(scratchpad2);
	scratchpad2=nextUlam(scratchpad2);
	scratchpad2=nextUlam(scratchpad2);
	scratchpad2=nextUlam(scratchpad2);
	scratchpad2=nextUlam(scratchpad2);
	printf("\n\n");
   
	return 0;
}