Giter Site home page Giter Site logo

ac's Introduction

ac's People

Contributors

sky-bro avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

ac's Issues

calculate/printf with double @noi~/1.4~/#20求一元二次方程的根

Origin: 20:求一元二次方程的根
can't get this right, my recent submitted code is:

#include <cstdio>
#include <cmath>

const double EPS = 1e-5;

int main(int argc, char const *argv[])
{
  double a, b, c;
  scanf("%lf%lf%lf", &a, &b, &c);
  double d = b*b;
  double e = 4*a*c;
  if (d>e) {
    double f = sqrt(e-d)/(2*a);
    printf("x1=%.5f;x2=%.5f\n", (-b+f)/(2*a), f, (-b-f)/(2*a), f);
  } else if (e>d) {
    double f = sqrt(e-d)/(2*a);
    double g = -b/(2.0*a);
    if (g < EPS && g > -EPS) g = 0.0;
    printf("x1=%.5f+%.5fi;x2=%.5f-%.5fi\n", g, f, g, f);
  } else {
    printf("x1=x2=%.5f\n", -b/(2*a));
  }
  return 0;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.