1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(int argc, char *args[]) {
  5. // get parameters from stdin
  6. float a, b, c;
  7. scanf("%f %f %f", &a, &b, &c);
  8. float d, e, f;
  9. scanf("%f %f %f", &d, &e, &f);
  10.  
  11. // variables for answer
  12. float x, y;
  13.  
  14. /** Explanation for solving problem
  15.   * =============
  16.   * ax + by = c
  17.   * dx + ey = f
  18.   * =============
  19.   * 1. multiplying LCM or just CM for removing x (or y)
  20.   * ===================
  21.   * d(ax + by) = d(c)
  22.   * a(dx + ey) = a(f)
  23.   * ===================
  24.   * 2. subtract with two equations
  25.   * =========================
  26.   * adx + dby = cd
  27.   * - adx + aey = af
  28.   * -----------------------
  29.   * (db - ae)y = cd - af
  30.   * =========================
  31.   * 3. get y
  32.   * ===============
  33.   * cd - af
  34.   * y = ---------
  35.   * db - ae
  36.   * ===============
  37.   * 4. get x
  38.   * ==============
  39.   * ax + by = c
  40.   * ==============
  41.   * c - by
  42.   * x = --------
  43.   * a
  44.   * ==============
  45.   * 5. solved
  46.   */
  47.  
  48. // error handling for dividing by zero
  49. if (d * b == a * e) {
  50. puts("-1");
  51. return 1;
  52. }
  53. y = (d * c - a * f) / (d * b - a * e);
  54.  
  55. // error handling for dividing by zero
  56. if (a == 0) {
  57. puts("-1");
  58. return 1;
  59. }
  60. x = (c - b * y) / a;
  61.  
  62. // print answer
  63. printf("%.01f\n", x);
  64. printf("%.01f\n", y);
  65.  
  66. return 0;
  67. }
  68.  


https://ideone.com/1Pqo2a


그렇다면 제대로 된 소스 푼다


주석도 달려있다