fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. typedefstruct field{
  6. char name[20];
  7. double cm,kg,BMI;
  8. structfield *next;
  9. int x;
  10. }cell;
  11.  
  12.  
  13. int main(void){
  14.  
  15. cell head,*a,*b,*new;
  16.  
  17.  
  18. head.next = NULL;
  19.  
  20. while (1) {
  21. new = (cell *)malloc(sizeof(cell));
  22. scanf("%s",&new->name);
  23.  
  24. if(new->name[0] != '0'){
  25.  
  26. scanf("%lf",&new->cm);
  27. scanf("%lf",&new->kg);
  28.  
  29. new->BMI = new->kg / (0.0001*new->cm*new->cm);
  30.  
  31. a = &head;
  32. b = b->next;
  33.  
  34. while (b != NULL && new->BMI > b->BMI) {
  35. a = b;
  36. b = b->next;
  37. }
  38.  
  39. new->next = b;
  40. a->next = new;
  41.  
  42. }
  43. else {
  44. break;
  45. }
  46.  
  47. }
  48.  
  49. for (a = head.next; a != NULL; a = a->next) {
  50. printf("%f %f %f %s\n", a->BMI,a->cm,a->kg,a->name);
  51. }
  52.  
  53. return0;
  54.  
  55. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:5: error: ‘typedefstruct’ does not name a type
prog.cpp:10: error: expected constructor, destructor, or type conversion before ‘;’ token
prog.cpp: In function ‘int main()’:
prog.cpp:15: error: ‘cell’ was not declared in this scope
prog.cpp:15: error: expected `;' before ‘head’
prog.cpp:18: error: ‘head’ was not declared in this scope
prog.cpp:21: error: expected type-specifier before ‘=’ token
prog.cpp:21: error: expected primary-expression before ‘)’ token
prog.cpp:21: error: expected `;' before ‘malloc’
prog.cpp:22: error: expected type-specifier before ‘->’ token
prog.cpp:22: error: lvalue required as unary ‘&’ operand
prog.cpp:24: error: expected type-specifier before ‘->’ token
prog.cpp:24: error: expected `)' before ‘->’ token
prog.cpp:26: error: expected type-specifier before ‘->’ token
prog.cpp:26: error: lvalue required as unary ‘&’ operand
prog.cpp:27: error: expected type-specifier before ‘->’ token
prog.cpp:27: error: lvalue required as unary ‘&’ operand
prog.cpp:29: error: expected type-specifier before ‘->’ token
prog.cpp:29: error: expected `;' before ‘->’ token
prog.cpp:31: error: ‘a’ was not declared in this scope
prog.cpp:32: error: ‘b’ was not declared in this scope
prog.cpp:34: error: expected type-specifier before ‘->’ token
prog.cpp:34: error: expected `)' before ‘->’ token
prog.cpp:34: error: expected primary-expression before ‘->’ token
prog.cpp:34: error: expected `;' before ‘)’ token
prog.cpp:39: error: expected type-specifier before ‘->’ token
prog.cpp:39: error: expected `;' before ‘->’ token
prog.cpp:40: error: expected type-specifier before ‘;’ token
prog.cpp:49: error: ‘a’ was not declared in this scope
prog.cpp:53: error: ‘return0’ was not declared in this scope
stdout
Standard output is empty