Last active
September 5, 2018 17:12
-
-
Save amirrpp/f580590c7fdd3678d2b9310b26b8c466 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
int main(void) { | |
char name1[18], name2[18], name3[18]; | |
char group1[3], group2[3], group3[3]; | |
char place1[30], place2[30], place3[30]; | |
unsigned int count1, count2, count3; | |
int col_len1 = 9, col_len3 = 16; | |
int name_len1, name_len2, name_len3; | |
int place_len1, place_len2, place_len3; | |
/* Введення фактичних даних */ | |
printf("1. Введіть: назва, група, місце проживання, чисельність >"); | |
scanf("%s %s %s %d", name1, group1, place1, &count1); | |
printf("2. Введіть: назва, група, місце проживання, чисельність >"); | |
scanf("%s %s %s %d", name2, group2, place2, &count2); | |
printf("3. Введіть: назва, група, місце проживання, чисельність >"); | |
scanf("%s %s %s %d", name3, group3, place3, &count3); | |
/* Виведення таблиці */ | |
/* Виведення заголовків */ | |
name_len1 = strlen(name1)/2; | |
name_len2 = strlen(name2)/2; | |
name_len3 = strlen(name3)/2; | |
place_len1 = strlen(place1)/2; | |
place_len2 = strlen(place2)/2; | |
place_len3 = strlen(place3)/2; | |
printf("|--------------------------------------------------------------|\n"); | |
printf("| Деякі види антилоп |\n"); | |
printf("|--------------------------------------------------------------|\n"); | |
printf("| Назва | Група | Місце проживання | Чисельність популяції |\n"); | |
printf("|-----------|-------|------------------|-----------------------|\n"); | |
/* Виведення рядків фактичних даних */ | |
printf("| %-*s | %s | %-*s | %21d |\n", | |
col_len1 + name_len1, name1, group1, col_len3 + place_len1, place1, count1); | |
printf("| %-*s | %s | %-*s | %21d |\n", | |
col_len1 + name_len2, name2, group2, col_len3 + place_len2, place2, count2); | |
printf("| %-*s | %s | %-*s | %21d |\n", | |
col_len1 + name_len3, name3, group3, col_len3 + place_len3, place3, count3); | |
/* Виведення приміток */ | |
printf("|--------------------------------------------------------------|\n"); | |
printf("| Примітка: |\n"); | |
printf("| А — справжні антилопи, |\n"); | |
printf("| В — коров'ячі антилопи, |\n"); | |
printf("| Н — кінські антолопи |\n"); | |
printf("|--------------------------------------------------------------|\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment