fork download
  1. #include <stdio.h>
  2. #include <stdlib.h> // for exit()
  3.  
  4. #define MAX_SEATS 1500
  5. #define INDENT "\t\t\t\t\t"
  6.  
  7. #define myexit(x) \
  8. char mys[256]; printf("\npathste ENTER gia ejodo..."); \
  9. fflush(stdin); fgets(mys, 256, stdin); exit( (x) )
  10.  
  11. // -------------------------------------------------------------------------------------
  12. int nsupers( int rseats )
  13. {
  14. if (rseats > 23)
  15. return 3;
  16.  
  17. if (rseats > 15)
  18. return 2;
  19.  
  20. return 1;
  21. }
  22.  
  23. // -------------------------------------------------------------------------------------
  24. int main( void )
  25. {
  26. int iroom; // μετρητής αιθουσών (δεν ζητήθηκε, είναι έξτρα)
  27. int rseats; // θέσεις αίθουσας (user input)
  28. register int booked = 0; // θέσεις που έχουν ήδη γεμίσει
  29.  
  30. booked = 0; iroom = 1;
  31. while ( booked < MAX_SEATS ) // για όσο οι γεμισμένες είναι λιγότερες της ζήτησης
  32. {
  33. printf("\nXwrhtikothta %dhs aithoysas? ", iroom++ );
  34. fflush(stdin);
  35. scanf("%d", &rseats);
  36. printf("%sapaitoymenoi Epithrhtes: %d\n", INDENT, nsupers( rseats ) );
  37.  
  38. booked += rseats; // αύξηση των γεμισμένων θέσεων κατά rseats
  39.  
  40. /*
  41. * από δω και κάτω δεν χρειάζεται, το έβαλα για εφέ :)
  42. */
  43.  
  44. int needmore = MAX_SEATS - booked;
  45. if ( needmore > 0)
  46. printf("%s(xreiazomaste akoma %d theseis)\n", INDENT, needmore);
  47. else if ( needmore == 0 )
  48. printf("%s(tsima tsima hrthame)", INDENT);
  49. else
  50. printf("%s(mas peirssepsan kai %d theseis)\n", INDENT, -needmore);
  51. }
  52.  
  53. myexit(0);
  54. }
  55.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty