0 like 0 dislike
1.6k 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 程式設計(一)AD by (18k points)
ID: 18069 - Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00

reshown by | 1.6k views

13 Answers

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

int
* * ** *** * **
* * * ** %.4f %.4f ****** ** ** * * * * **** * ** *

int n=0;
**

a=1;

b=n;
* * *
** * ** ** * ** %.6f * * **** **
answered by (-304 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



int main()

{
* ** * * * *** x,y,X,Y,a,b,c,g;

   int A,B,C,k;
* ***** * * * ** * * * ** ***** * ** ** **
** *** * *** *** ** * ** ** * **** **
* *** ** ** * * * * *** * ** ***
* * * ** ****** ** **** *** * * * ** * *** ** * *
** * ***** ** * * *** * ******** * ** *** * *****
** *** * * * * * ** *** * * ********** ** *
** *** ** *** ******* * * * ****

   else
* * * * *** **** * ** ** *** *
*** * * * **** **** *** ** * * * * * * ** * *
* * * * * ** ** * * *** ** * ******* **** ** * * * * **
* * * **** * ****** *** *** * ** * * *** ** ***** ** **
* * * * ***** * *** ******* **
** * * *** * * ******

   {
** * *** ** **** ** * * * ** * *** **** *** ** ** **** *
* ********* * ** *** *** * * *** * * ****
* * * * * * * *** * *** **** ** * * ** **** * * * * *
* * **** ** * * * * * * * *** * * * ** * * ** ** *
* * * ** * *** * *** ** ***

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

   b=B;

   c=C;

   if(a < 0)

   {
*** ** ** * ** **** * * *
** ** ** * * * * ** *** * ******
* ** *** * ****** ***** ** ** *

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

   {
* ** ** *** * * ***** ***
** * ** * * ** ** * ** * * * ** **

   }
** ** ** ** **** ** * * *
* * ***** * * *** *** * ***
* *** *** *** * *** **
* **** ******* * * *** * * * **
* ** **** *** ******* *
***** ** * * ** *** ** **** **** ***
*** * * * * * *** * * %f %f",a,b,c);
* ************* *** 0;

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



int main()

{
* ** ** * ** ** * * * a, b, c, d, m, e, i, j,q,w;
* ** * *** *** *** * * * * * * * *** **** ** ** *** * *
* * * ** * ** ***** = d-b;
** * ** ***** ** ** **** * = c-a;
*** * ** * * *** * * ** ** = i/j;
* * **** * * * * * * = a-c;
* **** *** ** ** ** * * * = ((b-d)*(a+c)+j*(b+d))/2;
* *** *** * * * * **** ** %f %f",i,q,e);
**** * * * * * **** *** **** * * *
******* ** ** * * * * * ** 0;

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

#include <stdlib.h>

#include <string.h>



int main(int argc, char *argv[]){
** *** * * ** ** ** * a,b,c,flag,x1,x2,y1,y2;
**** ** * * * ******
** * * * * ** * * *** **** ** * * * * * **** * * * * ** *** **
* ** ** * *** ** *** ** *** == x2){
****** *** * ** * * ** *** *** ** ** ** = x1;
* *** *** * ** *** * **** **** *** ** * * = 0;
* * * **** ** * * * * * *** *** **** = -1 * x1;
* * * ** * *** **** *
* * * *** * ** ** ** if(y1 == y2){
* ** ** ** * ** * ****** * * * ** * ** * ** * ** = 0;
* ** **** * *** ******* * *** * ***** *** ****** *** = y1;
* ** ** * * * * * *** * *** * *** ** * **** = -1*y1;
** *** **** *** *****
* *** ****
* *** *** * ** * ****
** * ***** * * *** * * ** *** * * * = (y1-y2)/(x1-x2);
** * **** * *** ** * ****** ** * ** = **** *** **
* *** *** ** * * * *** * *** *** **** * * = -1*(a*x1+b*y1);
* ** ** * * * * **
** ** * * * * * *
* *** * *** **** ** ***** **** %f %f\n",a,b,c);
* * ** * ***

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

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

#include<stdlib.h>



int main ()

{
* * ** ** ** ******** * **** a=0,
*** * *** * * ** * * * ****** * ** * * ** **** **** * * * *
* ****** * ** * * **** * * * ** * * ********
*** * ** * * * ***** * ** * ** ** * * ** * * ** * **
* ** * * ** ** ** * *** * ** * **** * *** *** ***** * **
* * ***** ** * **** * * *** ** * ** * ***
** * ******* * **** ** *** * * ** * ****** * * ** ** ***
* **** ** * * ****** ** ** ** ** * * * ***
** **** ** ** * ** ** *** *** *** *** * * **
* ****** ** ** *** * ***** ** * * * * * * **** * ****** ** *** *
** ** ** * * ** *** ** *
*** **** * ** **** * ** * * *** * *** * * &i1, &i2, &i3, &i4);
** * ** * * ** ** **
****** * * * ** * ** * = (i3 - i1)*10;
* * ** * ** ** *** ** = (i4 - i2)*10;
** *** * *** **
** * * ** * * *** ** = y;
** * * ** * ** ** * = x;
** ***** ** * *** * = -(a*i1+b*i2);

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

    
** ** ******* ** * * * ** **** ** %.6f %.6f", a, b, c);

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

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

#include <stdlib.h>



int main()

{
* * **** * *** * x,y,X,Y,a,b,c;
* * ** ** * * * ** ** * ******** * ** * *** * * ** * *****
* * * * *** ** *
* * *** * * ** ** **
* ** * ** ** ****** * * * *
*** ** ** * *** < 0)

   {
* ** ****** * ** ****** * ** *
* *** * * * * *** **** ******
* ** * * * ** * * * ***** ** **

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

   {
*** * ** * * * * * * ** ** *
***** ** * ** ** *** ** * ******* **
***** * * * ** ** *** *
* ** * * * * **
* * ****** * ** **** * * ****
* * ** ** *
*** * * ******* *** * * * * ****
*** * *** * * ****
* *** **** * * * **** ***** **** * ***** *
* * *** ** **** * * ***** * %f %f",a,b,c);
* * * *** ** * ** 0;

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

#include <stdlib.h>



int main()

{

   float x,y,X,Y,a,b,c;
** * ** ** * *** * ** ** ** ** ** ** * * ***** * * * ** ** *
* ** ** * * **
**** * **** * *** * *
* ** ***** * * *** *** **

   if(a < 0)
******** *** * * *** * ** *** ***
****** * ** ** ** **** * * * *** * *** ***** **** * *** ***
**** ** ** ** * *** ** ** ** *** ** * ** * ** ** ** *
** * * ** ** ** * * * ****** * * **
**** **** ******* * *** * * *****
** * * **** ** * *
** * * * ** **** * *****
* * ****** ** ** *
**** ****** **** * * * * ******* **
* ****** ** **** ** *
** * * * * ** **** ** * ** *** * **
* **** *** **** * ** ** * ** %f %f",a,b,c);
* * ** ** * 0;

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

#include <stdlib.h>

#include <string.h>



int main(int argc, char *argv[]){
** * ** * *** * * **** * a,b,c,flag,x1,x2,y1,y2;
** * *** * **** ******
** * ** *** * *** ** * ***** *** ** * **** **** * *** * * ** ** **** * *
*** ** *** * * * *** * ** == x2){
*** * *** * *** ** * ** ** * *** * * = x1;
* *** ** ** * * ** ***** ** ** = 0;
** * ** * * * * ** ** * * * ** * * * = -1 * x1;
** ***** * ** *** * * *
*** ***** * * * * ** * if(y1 == y2){
*** *** *** * * **** **** * * * * ******* **** = 0;
* ** * ****** ** * * ***** * ** *** * *** *** = y1;
** ** ** * * **** *** *** * **** ***** *** * ** * = -1*y1;
*** ** * ** * *
* ** *** * ***** ** * *
* ** * ** * ** ****
** ***** * * * ** * * ** * ** *** = (y1-y2)/(x1-x2);
** * *** * * ** * ** *** * * * * * * * ** < 0) a = -1*a;
** * * ** * * * * **** **** *** * ** *** = %f\n",a);
** ** ** ** **** * ** * * * * *** * = a*x1+y1;
*** ** * * * * *** ** * * *** * **** = %f\n",c);
* ** ** * * ** ** **** ** * * ****** ** ** = -1;
* *** * * ** * * * *
** * ** * * * * **
* * * * *** **** *** * * **** %f %f\n",a,b,c);
** ** **** * **

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

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



int main()

{
* ** **** * ** * x1 , y1 , x2 , y2;
* ***** * *** ** a, b , ac , bc , c1 ,c2 ,c ;

   
* * **** ** ** ******** ** ** * *** , &x1);

*** ** * * ***** **** ***** , &y1);
** * *** * * ** * ** * * ** * ** , &x2);

** * * * *** * * * ** ** ***** * , &y2);
* *** ** * * **
* *** *** ** * **
** * *** ***
****** *** ****** *
** *** ****** ***** ****
* *** ** * **** * ; * * * * * **** * * * * *** * **** * *
** * ******* * * ***** ***** * ** ** *** ** ******* * *** ******** * ****
** * * ** ***** * * * ** **** * * *** * ** * *** ** **** ** ****** * ** *** ** *
******* ** *** * *
* * **** * **** if(y1==y2)
* ** ** **
*** * ** * * **
* *** ** ** * *** * *
* * ** ** ****** ** * ** * * ** * ;   
** * ** * * * * ** * * *** *
* **** * * **
** * * * ** *** **
* * ** * * *
***** ** *** ** * *****
* **** * *
* * * ** ** * ** ****

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

   
** *** * ** * *

   
**** * * ** *
* *** ** * ** * ***
** ** * * *** ** * * %.6f " , a , b);
*** **** ** ** * ** * **** * * * * , c);

  

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

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

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

#include * **** ** *



int main()

{
* ** ** ** ***** * ** ** x,y,X,Y,a,b,c;
* ** **** * ** * * *** * * ** ** * * * * * ** * * *
* ** ** * *** ** **
*** * ** *** * * **
***** *** ** **** **** * ***
* *** ** **** *** *** * %f %f",a,b,c);
***** **** * ****** 0;

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

Related questions

0 like 0 dislike
5 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AD by Shun-Po (18k points)
ID: 18074 - Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 1.1k views
0 like 0 dislike
96 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AD by Shun-Po (18k points)
ID: 18072 - Available when: Unlimited - Due to: Unlimited
| 7k views
0 like 0 dislike
67 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AD by Shun-Po (18k points)
ID: 18068 - Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 5.4k views
0 like 0 dislike
11 answers
[Exercise] Coding (C) - asked Dec 1, 2016 in 2016-1 程式設計(一)AD by Shun-Po (18k points)
ID: 18065 - Available when: 2016-12-01 18:30:00 - Due to: 2016-12-01 21:00:00
| 1.6k views
0 like 0 dislike
0 answers
[Resource] asked Dec 1, 2016 in 2016-1 程式設計(一)AD by Shun-Po (18k points)
ID: 18084 - Available when: Unlimited - Due to: Unlimited
| 7 views
12,783 questions
183,442 answers
172,219 comments
4,824 users