예제 #1
0
파일: play.c 프로젝트: sdzharkov/ECS30
//ask the user for a play
void get_play(Board board) {
	int enter_row, enter_col;
	while(1){ //while still true, keep going through this loop
		printf("Enter row a row between 0-%d and a column between 0-%d: ", board.row - 1, board.col - 1);
		scanf("%d %d", &enter_row, &enter_col);
		enter_row = board.row - enter_row - 1;
		if (in_bounds(board, enter_row, enter_col)) {
			if (board.tile[enter_row][enter_col].revealed == '!') {
				if (option_2(board, enter_row, enter_col)) {
					break;
				}
				else {
					continue;
				}
			}
			else if (board.tile[enter_row][enter_col].revealed == '?') {
				if (option_3(board, enter_row, enter_col)) {
					break;
				}
				else {
					continue;
				}
			}
			else if (board.tile[enter_row][enter_col].revealed == '#') {
				if (option_1(board, enter_row, enter_col)) {
					reveal_board(board, enter_row, enter_col, 0); 
					break;
				}
				else {
					continue;
				}
			}
			else {
				printf("This tile is already revealed.\n");
				continue;
			}
		}
		else {
			continue;
		}
	}
	if (check_win(board)) {
			print_board(board);
			printf("You Won!!\n");
			exit (0); //end the program because the game is over and the user has lost 
	}

	if (isgameover(board)) {
			print_board(board);
			printf("You Lost :(\n");
			exit(0); //end the program because the game is over and the user has lost
	}
	return;
}
void main() {
    printf("********************************************************************\n");
    printf("                 Climate Temperature Viewer 2014 (1)                \n");
    printf("********************************************************************\n\n");

    //Printing Menu
    int menu_choice;
    printf("Select Option:\n");
    printf(" 1. The mean temperatures for any selected day and month.\n");
    printf(" 2. The highest maximum temperature reached for the selected month.\n");
    printf(" 3. Display the days with three highest maximum temperatures on each month.\n");
    printf(" 4. Display day of the month with the lowest temperature\n");
    printf(" 5. Display the number of \"hot\" days which has more than mean temperature of 28 Degree Celsius for the selected month in whole number\n\n");


    do {
        printf("Your Option: ");
        scanf("%d", &menu_choice);
        switch (menu_choice) {
        case 1:
            option_1();
            break;
        case 2:
            option_2();
            break;
        case 3:
            option_3();
            break;
        case 4:
            option_4();
            break;
        case 5:
            option_5();
            break;
        default:
            printf("Invalid Input\n");
        }
    } while (menu_choice<1 || menu_choice>5);
}
예제 #3
0
/**
 * Main.
 */
int main ()
{
    char* data = "data.txt";
	int input;
	int i;
	
	employee* head;
	employee* employees_array = NULL;
    
	
	head = load(data);
	
	if (head == NULL)
    {
        printf("Could not load %s.\n", data);
        return 1;
    }	
	
	do
	{
	    input = display_menu();
        
        switch (input)
        {
        case 1:
			employees_array = option_1(head, employees_array, 1);
            break;
        case 2:
			employees_array = option_2(&head, employees_array);
            break;
        case 3:
            employees_array = option_3(&head, employees_array);
            break;
        case 4:
            employees_array = option_45(&head, 4);
            break;
		case 5:
		    employees_array = option_45(&head, 5);
            break;
        case 6:
            employees_array = option_67(&head, 6);
            break;
        case 7:
		    employees_array = option_67(&head, 7);
            break;
        case 8:	
		    option_8(employees_array);
            break;
        }
    }
    while(input != 8);
	
	free_employees_array(employees_array);
	unload(&head);


    if (head != NULL)
    {
        printf("Could not unload %s.\n", data);
        return 2;
    }

	printf("\nGoodbye!\n\n");
    system("pause");
    return 0;
}