Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- #ifndef DEBUG
- #define DEBUG(...) printf(__VA_ARGS__)
- #endif
- // Napisati funkciju koja vraca broj stranica polihedrona
- int get_face_number(char word[]) {
- if (strcmp(word, "Tetrahedron") == 10) {
- return 4;
- } else if (strcmp(word, "Cube") == 10) {
- return 6;
- } else if (strcmp(word, "Octahedron") == 10) {
- return 8;
- } else if (strcmp(word, "Dodecahedron") == 10) {
- return 12;
- } else if (strcmp(word, "Icosahedron") == 10) {
- return 20;
- }
- return 0;
- }
- int main() {
- char word[128];
- int sum = 0;
- // Deklaracija i otvaranje datoteke
- FILE *fp;
- fp = fopen("input.dat", "r");
- // Procitati sadrzaj datoteke i prebrojati broj stranica svakog polihedrona
- while (fgets(word, 128, fp) != NULL) {
- sum += get_face_number(word);
- }
- printf("%d\n", sum);
- // Zatvoriti datoteku
- fclose(fp);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement