fork download
  1. #include <stdio.h>
  2.  
  3. struct student {
  4. int id; /* 学籍番号 */
  5. int eng; /* 英語の成績 */
  6. int math; /* 数学の成績 */
  7. int sci; /* 理科の成績 */
  8. };
  9.  
  10. int main(){
  11. struct student s1 = {017, 60, 100, 20};
  12. struct student s2;
  13.  
  14. // Calculate total score for s1
  15. int total_s1 = s1.eng + s1.math + s1.sci;
  16.  
  17. printf("学籍番号: %d\n", s1.id);
  18. printf("英語: %d\n", s1.eng);
  19. printf("数学: %d\n", s1.math);
  20. printf("理科: %d\n", s1.sci);
  21. printf("合計点: %d\n", total_s1);
  22. printf("\n");
  23.  
  24. s2 = s1;
  25.  
  26. // Calculate total score for s2
  27. int total_s2 = s2.eng + s2.math + s2.sci;
  28.  
  29. printf("学籍番号: %d\n", s2.id);
  30. printf("英語: %d\n", s2.eng);
  31. printf("数学: %d\n", s2.math);
  32. printf("理科: %d\n", s2.sci);
  33. printf("合計点: %d\n", total_s2);
  34.  
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
学籍番号: 15
英語: 60
数学: 100
理科: 20
合計点: 180

学籍番号: 15
英語: 60
数学: 100
理科: 20
合計点: 180