fork(6) download
  1. #include<stdio.h>
  2. int main() {
  3. int input, correctResultCount = 0;
  4. float result = 0.0;
  5. while (true) {
  6. scanf("%d", &input);
  7.  
  8. if (input < 0) {
  9. result--;
  10. break;
  11. }
  12. if (input % 2 == 0) {
  13. result = result - 0.5;
  14. }
  15. if (input % 2 != 0) {
  16. result++;
  17. correctResultCount++;
  18. }
  19. if (correctResultCount == 3)
  20. break;
  21. }
  22. printf("%.1f", result);
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 3464KB
stdin
1 2 5 6 7
stdout
2.0