Advertisement
Guest User

prog 5

a guest
Apr 23rd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4.  
  5. #ifndef DEBUG
  6. #define DEBUG(...) printf(__VA_ARGS__)
  7. #endif
  8.  
  9. // Napisati funkciju koja vraca broj stranica polihedrona
  10. int get_face_number(char word[]) {
  11. if (strcmp(word, "Tetrahedron") == 10) {
  12. return 4;
  13. } else if (strcmp(word, "Cube") == 10) {
  14. return 6;
  15. } else if (strcmp(word, "Octahedron") == 10) {
  16. return 8;
  17. } else if (strcmp(word, "Dodecahedron") == 10) {
  18. return 12;
  19. } else if (strcmp(word, "Icosahedron") == 10) {
  20. return 20;
  21. }
  22. return 0;
  23. }
  24.  
  25. int main() {
  26. char word[128];
  27. int sum = 0;
  28.  
  29. // Deklaracija i otvaranje datoteke
  30. FILE *fp;
  31. fp = fopen("input.dat", "r");
  32.  
  33. // Procitati sadrzaj datoteke i prebrojati broj stranica svakog polihedrona
  34. while (fgets(word, 128, fp) != NULL) {
  35.  
  36. sum += get_face_number(word);
  37.  
  38. }
  39.  
  40. printf("%d\n", sum);
  41.  
  42. // Zatvoriti datoteku
  43. fclose(fp);
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement