fork download
  1. #include<stdio.h>
  2.  
  3. struct Student{
  4. char* name;
  5. int number;
  6. };
  7.  
  8. struct Report{
  9. char* file;
  10. struct Student author;
  11. };
  12.  
  13. int len(char* file){
  14. int i;
  15.  
  16. for(i=0; *file++; i++);
  17. return i;
  18. }
  19.  
  20. int main(void){
  21. struct Report r1={"program", "Steve",30};
  22. struct Report r2={"john_report", "John", 2};
  23. struct Report r3={"0604","Mary",10};
  24. struct Report a;
  25.  
  26. if(len(r1.file) > len(r2.file)){
  27. a=r1;
  28. r1=r2;
  29. r2=a;
  30. }
  31.  
  32. if(len(r2.file) > len(r3.file)){
  33. a=r2;
  34. r2=r3;
  35. r3=a;
  36. }
  37.  
  38. if(len(r1.file) > len(r2.file)){
  39. a=r1;
  40. r1=r2;
  41. r2=a;
  42. }
  43.  
  44. printf("学籍番号:%d, ファイル名:%s\n",r1.author.number,r1.file);
  45. printf("学籍番号:%d, ファイル名:%s\n",r2.author.number,r2.file);
  46. printf("学籍番号:%d, ファイル名:%s\n",r3.author.number,r3.file);
  47. return 0;
  48. }
  49.  
Success #stdin #stdout 0.02s 1720KB
stdin
Standard input is empty
stdout
学籍番号:10, ファイル名:0604
学籍番号:30, ファイル名:program
学籍番号:2, ファイル名:john_report