fork download
  1. #include <stdio.h>
  2. #include <malloc.h> //malloc()を使うため
  3. #include <stdlib.h> //exit(1)を使うため
  4.  
  5. struct each_score {
  6. int tensu; //点数
  7. int goukaku; //合格・不合格
  8. };
  9.  
  10. struct SEISEKI {
  11. char name[50];
  12. struct each_score kokugo;
  13. struct each_score sugaku;
  14. };
  15.  
  16. void check_score(int borderline, struct SEISEKI *a)
  17. {
  18. a->kokugo.goukaku = (a->kokugo.tensu < borderline) ? 0 : 1;
  19. a->sugaku.goukaku = (a->sugaku.tensu < borderline) ? 0 : 1;
  20. }
  21.  
  22. void print_score(struct SEISEKI a)
  23. {
  24. char *goukaku[] = {"rejection","accept"};
  25.  
  26. printf("name: %s\n", a.name);
  27. printf("kokugo %d : %s\n", a.kokugo.tensu, gou[a.kokugo.goukaku]);
  28. printf("sugaku %d : %s\n", a.sugaku.tensu, gou[a.sugaku.goukaku]);
  29. }
  30.  
  31. int main()
  32. {
  33. struct SEISEKI *score;
  34. int num;
  35. int i;
  36.  
  37. printf("Input number of students >\n");
  38. scanf("%d", &num);
  39. score = (struct SEISEKI *)malloc(sizeof(struct SEISEKI) * num);
  40. if (score == NULL) }
  41. printf("Memory overflow\n");
  42. exit(1);
  43. for (i = 0; i < 3; i++) {
  44. scanf("%49s%d%d", score[i].name, &score[i].kokugo.tensu, &score[i].sugaku.tensu);
  45. check_score(60, &score[i]);
  46. }
  47. for (i = 0; i < 3; i++) {
  48. print_score(score[i]);
  49. }
  50. return 0;
  51. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘print_score’:
prog.c:27: error: ‘gou’ undeclared (first use in this function)
prog.c:27: error: (Each undeclared identifier is reported only once
prog.c:27: error: for each function it appears in.)
prog.c:24: warning: unused variable ‘goukaku’
prog.c: In function ‘main’:
prog.c:40: error: expected expression before ‘}’ token
prog.c:35: warning: unused variable ‘i’
prog.c:38: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
prog.c: At top level:
prog.c:41: error: expected declaration specifiers or ‘...’ before string constant
prog.c:41: warning: data definition has no type or storage class
prog.c:41: warning: type defaults to ‘int’ in declaration of ‘printf’
prog.c:41: error: conflicting types for ‘printf’
prog.c:41: note: a parameter list with an ellipsis can’t match an empty parameter name list declaration
prog.c:42: error: expected declaration specifiers or ‘...’ before numeric constant
prog.c:42: warning: data definition has no type or storage class
prog.c:42: warning: type defaults to ‘int’ in declaration of ‘exit’
prog.c:42: error: conflicting types for ‘exit’
prog.c:43: error: expected identifier or ‘(’ before ‘for’
prog.c:43: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token
prog.c:43: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘++’ token
prog.c:47: error: expected identifier or ‘(’ before ‘for’
prog.c:47: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token
prog.c:47: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘++’ token
prog.c:50: error: expected identifier or ‘(’ before ‘return’
prog.c:51: error: expected identifier or ‘(’ before ‘}’ token
stdout
Standard output is empty