fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int trees[3] = {24, 7, 16};
  6. int limit = 11;
  7. int allowedRemainder = 0;
  8. int mod = 0;
  9. int modCount = 0;
  10. int i;
  11. for (i = 0; i < 3; ++i)
  12. {
  13. allowedRemainder = (trees[i] / limit) - 1;
  14. mod = trees[i] % limit;
  15.  
  16. modCount += (allowedRemainder > 0) * (allowedRemainder * limit) + (allowedRemainder >= 0) * mod;
  17. printf("Loop %d: mod = %d\n", i, modCount);
  18. }
  19. printf("Amount to remove: %d\n", modCount);
  20. return 0;
  21. }
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
Loop 0: mod = 13
Loop 1: mod = 13
Loop 2: mod = 18
Amount to remove: 18