Example #1
0
File: 4.c Project: akydd/practicalc
int main(void)
{
	char dept_code_1[20];
	char dept_code_2[20];

	/* test data */
	flights[0] = create_flight_info("WS 1423", "LAX", "YEG",
			2011, 12, 25, 14, 9,
		       	2011, 12, 25, 6, 25);	
	flights[1] = create_flight_info("WS 1487", "LAS", "YEG",
			2011, 12, 25, 19, 50,
			2011, 12, 25, 23, 55);
	flights[2] = create_flight_info("TACAT 4024", "YYC", "YEG", 
			2011, 12, 25, 22, 0,
			2011, 12, 25, 22, 54);
	flights[3] = create_flight_info("WS 145", "YYC", "YEG",
			2011, 12, 25, 22, 30,
			2011, 12, 25, 23, 19);

	while (1 == 1) {
		(void)printf("Enter first departure code, 'Q' to quit: ");
		get_airport_code(dept_code_1);
		if (is_quit(dept_code_1) == 1) {
			(void)printf("Bye!\n");
			break;
		}

		(void)printf("Enter second departure code, 'Q' to quit: ");
		get_airport_code(dept_code_2);
		if (is_quit(dept_code_2) == 1) {
			(void)printf("Bye!\n");
			break;
		}

		(void)printf("Seearching for %s...\n", dept_code_1);
		search_flights(dept_code_1);

		(void)printf("Seearching for %s...\n", dept_code_2);
		search_flights(dept_code_2);
	}

	/* clear allocated mem */
	int i;
	for(i = 0; i < MAX_FLIGHTS; i++) {
		free_flight_info(flights[i]);
	}

	return 0;
}
Example #2
0
int main() {
  int n, i;
  int locations[N];
  char cmd[M];
  Stack stacks[N];

  scanf ("%d\n", &n);
  for (i=0; i<n; i++) {
    stacks[i].top = 0;
    push (&stacks[i], i);
    locations[i] = i;
  }

  while (fgets (cmd, M, stdin)) {
    if (is_quit (cmd))
      break;
    run_cmd (stacks, locations, cmd);
  }

  output (stacks, n);
  return 0;
}