fork download
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<stdlib.h>
  4.  
  5. int member(char *,struct cell *);/*条件2*/
  6.  
  7. struct cell{/*条件1*/
  8. char animal[20];
  9. struct cell *next;
  10. };
  11. struct cell *listhead;
  12.  
  13. int main(){
  14. char animal[20];
  15.  
  16. struct cell ani1;
  17. listhead = &ani1;
  18. strcpy(ani1.animal,"rat");
  19.  
  20. struct cell ani2;
  21. ani1.next = &ani2;
  22. strcpy(ani2.animal,"cat");
  23.  
  24. struct cell ani3;
  25. ani2.next = &ani3;
  26. strcpy(ani3.animal,"dog");
  27.  
  28. struct cell ani4;
  29. ani3.next = &ani4;
  30. strcpy(ani4.animal,"elephant");
  31.  
  32. struct cell ani5;
  33. ani4.next = &ani5;
  34. strcpy(ani5.animal,"horse");
  35.  
  36. struct cell ani6;
  37. ani5.next = &ani6;
  38. strcpy(ani6.animal,"bat");
  39.  
  40. struct cell ani7;
  41. ani6.next = &ani7;
  42. strcpy(ani7.animal,"hamster");
  43. ani7.next = NULL;
  44.  
  45. while(strcmp(animal,"00") != 0){
  46. printf("動物名を英語で入力して下さい。(00で終了)-->");
  47. scanf("%s",animal);
  48. if(member(*animal,*next) = 1){
  49. printf("%sは存在します。\n",animal);
  50. }else if(member(*animal,*next) = 0){
  51. printf("%sは存在しません。\n",animal);
  52. }
  53. if(strcmp(animal,"00") = 0){
  54. printf("終了します。\n");
  55. return 0;
  56. }
  57.  
  58.  
  59.  
  60. }
  61.  
  62. }
  63.  
  64.  
  65. int member(char *animal,struct cell *next){
  66. if(strcmp(ani1.animal,"rat") == 0){
  67. return 1;
  68. }else if(strcmp(ani2.animal,"cat"){
  69. return 1;
  70. }else if(strcmp(ani3.animal,"elephant"){
  71. return 1;
  72. }else if(strcmp(ani4.animal,"horse"){
  73. return 1;
  74. }else if(strcmp(ani5.animal,"bat"){
  75. return 1;
  76. }else if(strcmp(ani6.animal,"hamster"){
  77. return 1;
  78. }else{
  79. return 0;
  80. }
  81. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:48: error: ‘next’ was not declared in this scope
prog.cpp:53: error: lvalue required as left operand of assignment
prog.cpp:47: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
prog.cpp: In function ‘int member(char*, cell*)’:
prog.cpp:66: error: ‘ani1’ was not declared in this scope
prog.cpp:68: error: ‘ani2’ was not declared in this scope
prog.cpp:68: error: expected `)' before ‘{’ token
prog.cpp:81: error: expected primary-expression before ‘}’ token
prog.cpp:81: error: expected `;' before ‘}’ token
stdout
Standard output is empty