fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. float x, y;
  5. printf("请输入 x 的值:");
  6. scanf("%f", &x);
  7.  
  8. if (x < 1) {
  9. y = x;
  10. } else if (x < 10) {
  11. y = 2 * x - 1;
  12. } else {
  13. y = 3 * x - 11;
  14. }
  15.  
  16. printf("y = %.2f\n", y);
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5320KB
stdin
5 1000 2000 3000 4000 5000
stdout
请输入 x 的值:y = 9.00