Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <math.h>
- void write_spaces(int xnum, int rowlenght)
- {
- int num_of_spaces = round((double)(rowlenght - xnum) / (double)(xnum+1));
- for (int i = 0; i < xnum; i++)
- {
- for (int j = 0; j < num_of_spaces; j++)
- {
- printf(" ");
- }
- printf("X");
- }
- printf("\n");
- }
- void write_players(char **str, int num, int rowlength)
- {
- int lenght_of_names = 0;
- for (int i = 0; i < num; i++)
- {
- lenght_of_names += strlen(str[i]);
- }
- int num_of_spaces = round((double)(rowlength - lenght_of_names) / (double)(num + 1));
- for (int i = 0; i < num; i++)
- {
- for (int j = 0; j < num_of_spaces; j++)
- {
- printf(" ");
- }
- printf("%s", str[i]);
- }
- printf("\n");
- }
- void print_formation(char **p, int formation)
- {
- int row_lenght = 150;
- switch (formation)
- {
- case 244:
- {
- char *first_row[] = { p[0], p[1] };
- char *second_row[] = { p[2], p[3], p[4], p[5] };
- char *third_row[] = { p[6], p[7], p[8], p[9] };
- write_spaces(2, row_lenght);
- write_players(first_row, 2, row_lenght);
- printf("\n");
- write_spaces(4, row_lenght);
- write_players(second_row, 4, row_lenght);
- printf("\n");
- write_spaces(4, row_lenght);
- write_players(third_row, 4, row_lenght);
- printf("\n");
- }
- break;
- default:
- printf("Rosszul megadott formacio! Adjon meg letezo adatot.");
- break;
- }
- }
- int main()
- {
- char *str[10] = { "Korcsma Istvan", "Programmer Pista", "Vicces Valeria", "Monoton Mark", "Slager Tibor", "Bunyos Pityu", "Fasy Adam", "Kis Grofo", "Skrillex", "The Midnight"};
- //formációk: 244, 334, 343, 433
- print_formation(str, 244);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement