Ejemplo n.º 1
0
/* When recieving "--print" as part of execution, runs all tasks as specified below */
void do_all(match_s *match, team_s *team, int number_of_matches, int number_of_rounds) {
    printf("The program will now execute all six tasks:\n");

    printf("\nTask one:\n");
    printf("Print all matches that has 7 or more goals total:\n");
    task_one(match, number_of_matches); printf("\n");

    printf("\nTask two:\n");
    printf("Print the first round with most goals.\n");
    task_two(match, number_of_rounds); printf("\n");

    printf("\nTask three:\n");
    printf("Get the teams that win more mathces out than home:\n");
    task_three(team); printf("\n");

    printf("Task four:\n");
    printf("Print the team with fewest spectators when playing home.\n");
    task_four(team); printf("\n");

    printf("Task five:\n");
    printf("Print the matches in a specific time interval, and sort them by number of goals.\n");
    task_five(match, number_of_matches, "18.05", "19.05", "Fre"); printf("\n");

    printf("Task six:\n");
    printf("Print the result for the end of the season.\n");
    task_six(team, number_of_rounds);
}
Ejemplo n.º 2
0
int main()
{
    printf("=================================================================\n");
    printf("Here you can see the list of the tasks that you can choose\n");
    printf("Type number from 1 to 10. For exit type 11\n");

    int num_task = 0;

    while (num_task != (11))
    {
        if( scanf("%d", &num_task) == 1)
        {
            assert(num_task > 0);
            switch(num_task)
            {
                case(1): task_one();
                    break;
                case(2): task_two();
                    break;
                case(3): task_three();
                    break;
                case(4): task_four();
                    break;
                case(5): task_five();
                    break;
                case(6): task_six();
                    break;
                case(7): task_seven();
                    break;
                case(8): task_eight();
                    break;
                case(9): task_nine();
                    break;
                case(10): task_ten();
                    break;
                case(11): printf("Here we go! Program is finished.\n");
                    break;
                default: printf("Wrong value! It should be positive int from 1 to 10!\n");
                    break;
            }
        }
        else
        {
            printf("ERROR! Your value is not int! Try again!\n");
            scanf("%d", &num_task);
        }
        printf("\n");
    }

    printf("Nice to see you! Have a nice day :) \n");
    return 0;
}
Ejemplo n.º 3
0
//!=====================================================================
void task_eight(void)
{
    task_three();
}
Ejemplo n.º 4
0
int main(int argc, char **argv)
{
    /* Prepares globally used data on program start_up */
    int number_of_lines = 0, number_of_matches = 0, number_of_rounds = 0, match_number = 0, user_input = 0;
    char **file_string, early[STR_LEN2], late[STR_LEN2], weekday[STR_LEN];
    match_s *match; /* Note: Array declared, but not allocated or initialized */
    team_s *team; /* Note: Array declared, but not allocated or initialized */

    get_number_of_lines(&number_of_lines);
    get_number_of_matches(number_of_lines, &number_of_matches);
    get_number_of_rounds(number_of_lines, &number_of_rounds);
    file_string = (char **)calloc(number_of_lines,sizeof(char *));
    for(match_number = 0; match_number < number_of_matches; match_number++) {
        file_string[match_number] = (char *)calloc(LINE_LENGTH,sizeof(char));
    }
    read_file(file_string);
    match = (match_s *)calloc(number_of_matches,sizeof(match_s));
    save_file_to_struct(match, file_string, number_of_lines);

    team = (team_s *)calloc(NUMBER_OF_TEAMS,sizeof(team_s));
    get_teams(team, match, number_of_matches);

    /* Run program with user interaction */

    if(argc == 2 && strcmp(argv[1], "--print") == 0) {
        do_all(match, team, number_of_matches, number_of_rounds);
    } else {
        printf("Please input a numner between 1 and 6 to run said program.\nInput 0 to exit the program:\n");
        printf("Input:>> ");
        scanf("%d",&user_input);

        while(user_input != 0) {

            switch (user_input) {
            case 1:
                printf("\nTask one:\n");
                printf("Print all matches that has 7 or more goals total:\n");
                task_one(match, number_of_matches);
                break;
            case 2:
                printf("\nTask two:\n");
                printf("Print the first round with most goals.\n");
                task_two(match, number_of_rounds);
                break;
            case 3:
                printf("\nTask three:\n");
                printf("Get the teams that win more mathces out than home:\n");
                task_three(team);
                break;
            case 4:
                printf("Task four:\n");
                printf("Print the team with fewest spectators when playing home.\n");
                task_four(team);
                break;
            case 5:
                printf("Task five:\n");
                printf("Print the matches in a specific time interval, and sort them by number of goals.\n");
                prompt_time(early, late, weekday);
                task_five(match, number_of_matches, early, late, weekday);
                break;
            case 6:
                printf("Task six:\n");
                printf("Print the result for the end of the season.\n");
                task_six(team, number_of_rounds);
                break;
            default:
                printf("Invalid user input!\n");
                break;
            }

            user_input = 0;

            printf("\nTo perform another task, input a number from 1 - 6.\nTo exit, input 0.\n");
            printf("Input:>> ");
            scanf("%d",&user_input);
        }
    }

    free(match);
    free(team);

    return 0;
}