fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6. float x, y, u;
  7. scanf("%f%f", &x, &y);
  8. float a=x*x+y*y;
  9. if((y<0)||(a>1)||((x>0)&&(a<0.3)))
  10. {
  11. printf("u=%f", sqrt(abs(x-1)));
  12. }
  13. else
  14. {
  15. printf("u=%f",x*x-1);
  16. }
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 4548KB
stdin
0.3 0.3
stdout
u=0.836660