zoukankan      html  css  js  c++  java
  • 1027 方程组的根

     1 // Test1027-求方程的根.cpp: 定义控制台应用程序的入口点。
     2 //
     3 
     4 #include "stdafx.h"
     5 #include <math.h>
     6 int mark = 0;
     7 float haha(int a, int b, int c)
     8 {
     9     float temp = b * b - 4 * a*c;
    10     if (temp < 0)
    11     {
    12         temp = -temp;
    13         mark = 1;
    14     }
    15     else
    16     {
    17         mark = 0;
    18     }
    19     return sqrt(temp);
    20 }
    21 
    22 int main()
    23 {
    24     int a, b, c;
    25     float result1,result2;
    26     scanf_s("%d %d %d", &a,&b,&c);
    27     float h1, h2;
    28     h1 = -(float)b / (float)(2 * a);
    29     float h3 = haha(a, b, c)/(2*a);
    30 
    31     if (mark == 0)
    32     {
    33         h1 = h1 + h3;
    34         h2 = h1 - h3;
    35 
    36         printf("x1=%.3f x2=%.3f", h1, h2);
    37     }
    38     else if (mark == 1)
    39     {
    40         printf("x1=%.3f+%.3fi ", h1, h3);
    41         printf("x2=%.3f-%.3fi ", h1, h3);
    42     }
    43 
    44     //printf("%.3f", result);
    45     return 0;
    46 }

    万事走心 精益求美


  • 相关阅读:
    Java-笔记9-复习
    Java-笔记9
    Java-笔记8-复习
    Java0-笔记8
    Java-笔记7-复习
    hadoop-hdfs-ha配置-搭建
    Java-笔记7
    Java-笔记6-复习
    kettle-作业和参数
    kettle-脚本控件
  • 原文地址:https://www.cnblogs.com/kongchung/p/9330528.html
Copyright © 2011-2022 走看看