0 like 0 dislike
5.4k views
直線方程式的通式為 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)
ID: 18070 - Available when: Unlimited - Due to: Unlimited

reshown by | 5.4k views

49 Answers

0 like 0 dislike
Hidden content!
// *** *** * by HoMingJui on 2016/11/3.

//



#include * * **** **

#include **** ** * *

#include * ** *

#include * * * *





int main(){
** **** * ** ** ** * x[2],y[2],a,b,c;
* *** ** * * ** ** ***** * %f %f *** *** * *** * ** * *** **** ** * *
** * * * * * *** * * **** *
***** ** *** ** ** * **** ** ** * * ** *
** *** * ** *** * ** ** *** *** * ***
*** **** ***** * * *** ** * *** * %.6f *** * ** **
* * * ** * * *** * 0;

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



int main()

{
** * * * ** * **** a1,a2,b1,b2,a,b,c;
* *** * *** ******* ** %f %f ** *** *** ** * ** *** * *****
* ** ***** * **
* ** * * * * *** * *
* ** ****** * * **** * ***
* ** * *** ** * * ** %.6f %.6f",a,b,c);


* * * ** * ** *** 0;

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



int main()

{
* * ** ***** * * ** a1,a2,b1,b2,a,b,c;
* ** * ** ** ** * *** * * %f %f *** ** * ** * * *** **** * * *
*** * *** *** ** *** **
* * * * * *** * ***** *
* * * * * ***
** *** * * * **
* ** *** ** ***** * **** * %.6f %.6f",a,b,c);


**** * * * * ** * *** 0;

}
answered by (-124 points)
0 like 0 dislike
Hidden content!
#include * *** * *



int main(void){


*** * ** * * * * * ax , ay ,bx ,by ,a ,b * *******


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


** ***** * * ** * ** * - bx) != 0){
*** * * * * * * = (ay - ** **
* * * *** * **** = -m*ax + ay;
* **** * * ** ***** = m;
** * * * * * * = 1;
** ***
* ** ***** **
** * ** *** ** = 0;
* * *** * ** *** = 1;
* ** *** * = -ax;
* * **


** **** * *** * * ** * = a;
* * ** *** ** * * * = b;
**** **** * * = c;


*** * ** < 0)
* **** ** * ****** * = -i;
** if (k < 0)
* * ** * * **** = -k;


* *** (i < 1){
* * ****** * * **** = 1/i;
* ** * *** ***** *** = a*g;
*** * * * * *** = b*g;
* *** ** ** ** ** = c*g;
* * * *
*** * * if (k < 1){
**** ** * * *** *** ** = 1/k;
* **** * * *** = a*g;
** * * = b*g;
** * * * ** = c*g;

 }
* * * ***** * ******
* ** ***** * ***
* * ** ** * ** *



return 0;

}
answered by (-122 points)
0 like 0 dislike
Hidden content!
#include * * * ** *



int main(void){


* *** * * * * * ** ax , ay ,bx ,by ,a ,b * *


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


* ** * * * **** * - bx) != 0){
* * *** ** * ** ***** * = (ay - ** **
* ** * * * * ** ** = -m*ax + ay;
* *** ** * = m;
*** *** * * * * = 1.000000;

** * * ***** * *
* * ** * ** ****** = 0.000000;
** * * ***** = 1.000000;
* * ** * ** ** = -ax;
* **


*** * * * * * * = a;
* ** ****** ** * = b;
** * * * *** = c;


** *** * < 0)
** ***** * * ** ** = -i;
* ** * if (k < 0)
* *** *** * ** * *** * = -k;


** **** (i < 1){
***** ** *** * * = 1/i;
** * ** * * * = a*g;
*** **** ***** * = b*g;
** ** * ** * ** * = c*g;
* ** *
* * **** **** if (k < 1){
* * * **** * ** * = 1/k;
* * * * ** ** * = a*g;
* * * *** = b*g;
* * ***** *** ** = c*g;
* **
**** *** * ** ** * * *
* * ** *** * *
** * * ** * ** * *



return 0;

}
answered by (-122 points)
0 like 0 dislike
Hidden content!
* * * * ** * **
* * * ** * *
*** ** *
** i * * * *
* ** a , b , c , *** ** ** * *
*** *** ; i ** * ; *
* * ** * , * * * );




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



**** * *** * ** * ** *
**
* * **** * * * **
* = * * ** * ;
= ;

** ** ** ** * * ** * a , b








* 0 ;






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

int main()

{
** * **** ** * * *** a,b,c,d,m,x,y;
*** * * * * ** * ** * * ** * %f %f ** * * ****** * *** ** *
**** * * * ** * * * *
** * * ********** ** * ** * * **

}
answered by (-103 points)
0 like 0 dislike
Hidden content!
#include *** * * * *



int main(void){


* * * * * * * ** ** ax , ay ,bx ,by ,a ,b ,k,m,c;


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


*** ** * * * ** * *** * - bx) != 0){
* *** ** * = (ay - ** **
** * * **** * = -m*ax + ay;
**** ** ** * ** = m;
* *** ** * * = 1.000000;

 }
** * * * *** **
* ** * * **** *** ** = 0.000000;
*** **** * * ** * = 1.000000;
** * * ** = -ax;

 }


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



return 0;

}
answered by (-122 points)
0 like 0 dislike
Hidden content!
#include * * * *



int main(void){


** *** *** * **** * ax , ay ,bx ,by ,a ,b ,k,m,c;


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


** * * ** ** ** - bx) != 0){
** ***** ** * * = (ay - ******
* * * * * * * = m*ax + ay;
* *** * *** = m;
* * ** * *** = 1.000000;

 }
* * * * ** ** **
*** ** ** ** * = 0.000000;
* ** ** ** **** = 1.000000;
* * * *** * * ** ** * = -ax;

 }


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



return 0;

}
answered by (-122 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.7.77
©2016-2025

Related questions

0 like 0 dislike
16 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 18075 - Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 2.8k views
0 like 0 dislike
86 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 18071 - Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 9.4k views
0 like 0 dislike
62 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 18067 - Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 7.5k views
0 like 0 dislike
21 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 18066 - Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 3.3k views
0 like 0 dislike
0 answers
[Resource] asked Dec 1, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 18085 - Available when: Unlimited - Due to: Unlimited
| 10 views
12,783 questions
183,442 answers
172,219 comments
4,824 users