fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. float a, b, c;
  7. int isInt;
  8. do {
  9. puts("Please enter three positive lengths:");
  10. isInt = scanf(" %f %f %f", &a, &b, &c);
  11. if (isInt != 3) {
  12. printf("Not enough inputs: %d\n", isInt);
  13. scanf("%*[^\n]");
  14. a = b = c = -1;
  15. continue;
  16. }
  17. } while(a <= 0 || b <= 0 || c <= 0);
  18. printf("%f %f %f", a, b, c);
  19.  
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 3464KB
stdin
1 2 xxx
2 x 333
1 2 -3
10.1 20.2 30.3
stdout
Please enter three positive lengths:
Not enough inputs: 2
Please enter three positive lengths:
Not enough inputs: 1
Please enter three positive lengths:
Please enter three positive lengths:
10.100000 20.200001 30.299999