Esempio n. 1
0
//
// restore window position
//
void restoreSettings(const char *configName, SDL_Rect &rect, int &fontScale) {
  FILE *fp = openConfig(configName, "r");
  if (fp) {
    rect.x = nextInteger(fp, SDL_WINDOWPOS_UNDEFINED);
    rect.y = nextInteger(fp, SDL_WINDOWPOS_UNDEFINED);
    rect.w = nextInteger(fp, DEFAULT_WIDTH);
    rect.h = nextInteger(fp, DEFAULT_HEIGHT);
    fontScale = nextInteger(fp, DEFAULT_SCALE);
    opt_mute_audio = nextInteger(fp, 0);
    fclose(fp);
  } else {
    rect.x = SDL_WINDOWPOS_UNDEFINED;
    rect.y = SDL_WINDOWPOS_UNDEFINED;
    rect.w = DEFAULT_WIDTH;
    rect.h = DEFAULT_HEIGHT;
    fontScale = DEFAULT_SCALE;
  }
}
/**
 * @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;
}