0 like 0 dislike
直線方程式的通式為 ax+by+c=0 ,請設計一程式,由使用者輸入平面上兩點,程式會計算出直線方程式後輸出a, b, c。

輸入說明:輸入會包含四個浮點數,倆倆之間會用一個空白隔開,四個浮點數依序代表第一個點的x座標、第一個點的y座標、地按個點的x座標、第二個點的y座標。

輸出說明:請依序輸出 a, b, c 三個常數,每個數都需輸出到小數點後六位。請確保a, b, c 間的最大公因數為1。

輸入範例:

1.0 1.0 1.0 2.0

輸出範例:

1.000000 0.000000 -1.000000
[Exercise] Coding (C) - asked in 2016-1 程式設計(一)AC by (18k points)
Available when: Unlimited - Due to: Unlimited

reshown by | 51 views

49 Answers

0 like 0 dislike
Hidden content!
** *** *** ** *


** * **** * *


**** * ** *


** * * *** *




* ** ( *

*** *
* ** ** ** ** * * * * * * *** *** * ** ** *
= d - **
= c - **
* = f * b - a * e ;
* = 0 - *
* *
*
* ** ** * ***** ** *** * * = - * * * * **



*** * * * ** ** ** *
** *
answered by (-276 points)
0 like 0 dislike
Hidden content!
* ***** * *


* *
** * ** **** *** * ******** ** * *** * * t = 0, a, b, c, a1 , * **


** * *** * * * * *** * *** %f %f * **** * ** ** * *** *** * *




** * ********* * * ** = ** - * / * y2 - x2 * *
* *** ***** *** ** * * = *** - ** / * ** - * * *
* ** **** * *** * * = - * * * - * *


* ** * ** ** ** *** *** * * ** * * * *


**

}
answered by (-105 points)
0 like 0 dislike
Hidden content!
* *** *** * **





int main(void)

{
* **** * * * * * *** **
* **** * ** ***** %f %f * * ** ** *** * ** ** ** ***
* * ** ** - x2 == * **** * != 0)
**** * **
** *** ** * ** *** = x1;
**** * ** ** ** * = 0;
**** ** * * ******** * = -x1;
* ** * * * ****** * * * **** %f *** * *
* **** ** ** ** *
*** *** if(x1 - x2 != ** * * * * != 0)
** *
******* ** ****** = (y1 - y2)/(x1 - x2);
* * *** * * * * = y1 - (a * x1);
** **** ***** * = -((a * x1) + c) / y1;
* * * * * * %f * * ** *****
** *
* ** * if(x1 - x2 != ** ** * == 0)
** *
******* * *** *** * = x2;
* * * * ** ** **** = 0;
* ** * **** * = -x2;
*** * ***** * * **** ** ** * ** %f * ** * ****
***
* * ** ** ** if(x1 - x2 == * ***** == 0)
* *
** * *** * * ***** * = 1;
* * ** * **** *** = 0;
* **** * **** ** *** = 0;
* ** * ******** ** * ** * *** ** * %f ***

 }
* ** * 0;

}
answered by (-100 points)
0 like 0 dislike
Hidden content!
*** * * * **


*** * * * ****


** * *** * ** ** ****


** ***** * **** *




* * ( *

*** *** ** * **
* ** * * *** * ***** * * ** *** * **** *
* = d - **
* = c - *
* = f * b - a * e ;
= 0 - *
*** **

* ** **** *** ** ** ******* = * - * * **



* * ** * * * * **
** * *
answered by (-276 points)
0 like 0 dislike
Hidden content!
* * * ** ** *


* *
**** * ** * * * * ** * * * * ** * ** * t = 0, a, b, c, a1 , **


* * * * * * **** * * * * %f %f * * ** *** ***** ** * *** ** * * *




** * * *** ** * * * * = * - * / * y2 - x2 * **
* ** ****** * ** = ** - / * * y2 - * **
* ***** * ** ****** = - * * - * *
*** * * * * ** * **** * = a * -
****** * * * ** ** * = b * -
** * * * ** ** * ** * ** ** *** *** ** * * * * * *


* * 0;

}
answered by (-105 points)
0 like 0 dislike
Hidden content!
**** * * *


** * *
**** * * * *** * * * * * * * t = 0, a, b, c, a1 ,


* * * ** * * ** **** ** ** * %f %f *** *** * * * * ** ** ** ** *




** ** ** ** *** **** * ** = - * / * * y2 - x2 * ***
*** ** * ** * * **** *** = - ** / * * y2 - * * *
** * ** * **** * * = - * - ** * ***
*** **** * * * *** ** ** * = a / - *
* * *** * * *** = b / -
* * ** **** *** ** * * ** * * ** ** ** * *** * ** *** *


* * * 0;

}
answered by (-105 points)
0 like 0 dislike
Hidden content!
* ** ** * **** *** *


*** * ** *
* * *** **** * * ** ** ** * * * ** * * t = 0, a, b, c, a1 , *


*** * * * **** * * ** %f %f ** * * ** * * **** ** * * ***




** * **** * * **** ***** = - * * / * * y2 - x2 * *
* * ** * * * ** ** * = ** - * / * y2 - * *
* ** * ** ** * ** * * *** = - * * * - * * *
* ** *** * ** *** * = a / - *
** **** * * * *** ** ***** = b / -
** * * * * *** ***** **** * ** * ** *


*** 0;

}
answered by (-105 points)
0 like 0 dislike
Hidden content!
* **** * ****





int ** **

{
* ** * * ** * *
* * * * *** ** * * %f %f * * ** * * ** * *** ****** *
* * **** - x2 == 0,y1 != 0)
* * *
*** ** * **** * ** = x1;
* *** * *** * * *** = 0;
* ** ** * ***** * * *** * = -x1;
* * * * **** * ** * * * ****** ** %f ** ** **** *
*** * *** * *
* * if(x1 - x2 != 0,y1 != 0)
* *** *
** * *** * ***** = (y1 - y2)/(x1 - x2);
* *** *** * * * * = y1 - (a * x1);
*** ** * ** = -((a * x1) + c) / y1;
* ** **** * * ** ** * ** ** %f * *** ***
* **
* * * *** if(y1 == 0)
* *
* ** * * *** * * * * **** = x2;
* * * ** * * * * *** * = 0;
* * *** *** *** ******* * = -x2;
* ** ** * * * ** * * * * * %f *** *** *** ***
* ** *
* **** * 0;

}
answered by (-100 points)
0 like 0 dislike
Hidden content!
* **** * * * **


* **** * * ** *


** ** *** *


* ** * * * *** *




* * ( **

* **** *
* * * * * * * **** *** *** ** * * ***** *
* = d - *
= c - *
** = f * b - a * e ;
** = 0 - **
*** * **

* * * * * *** **** ** = * - * * * *
*


* * **** * ****
**
answered by (-276 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<stdlib.h>

#include<ctype.h>

#include<math.h>



int main()

{
** ** ** **** ** * * ** x1,x2,y1,y2,m,a,b,c,c0;
*** **** * ** * ** ** * *** *** * * ****
***** ** ** *** *** * * *** * *** * * * * * ****
* *** ** ** * **** ***** ***** ***** ** *
*** * ** ***** * *** * * * **** ** **

    m = (y1-y2)/(x1-x2);
*** * ** * * ** *** * * ** * * *
* * **** *** * *** * * ****
****** * * ** ** ***** * * *
** ** * *** *** *** *** * *****
*** ** *** * * ** ***** *** * *
****** * ** ** * ** ** * ** ** * * * *** * * ** *** %f %f",m,-1.000000,c0);
**** *** * *** ** *** **** if((y1-y2)%(x1-x2)!=0.000000)
* * * * **** ** ** * *** ** *** *** * *** ** * * ** *** ** **
* * * ** * ** ** ** * * *** * * **** *
** ** ** * *** * ** ** *** * * ** * ** * ** ** ** * * *** ** **
* * ** * * * * * * * * ** * * * * *************** * ** *** * **
***** ** * ** ** * * ** * * * *** *** * * * * * ** ** ** * * ****
* * * ** * *** * * * * * ** * ** *** *** *


* ** ** ** **** ** ** * ****** ****** ** **


* * * ** * *** * * * * ** * * ***** **** ** %f %f",m*i,-1*i,i*c0);

return 0;

}
answered by (-102 points)
Get it on Google Play Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.69.10
©2016-2019

Related questions

0 like 0 dislike
16 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 60 views
0 like 0 dislike
86 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 94 views
0 like 0 dislike
62 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 66 views
0 like 0 dislike
21 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 53 views
0 like 0 dislike
0 answers
[Resource] asked Dec 1, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
Available when: Unlimited - Due to: Unlimited
| 10 views
8,033 questions
60,929 answers
33,033 comments
1,102 users