① 求一c語言編程,輸入坐標(x,y)後得到的輸出結果是(y,x)。。求大神指導啊。。
#include <stdio.h>
int main()
{
float x,y;
printf("please enter x,y: ");
scanf("%f,%f",&x,&y);
printf("%5.2f,%5.2f ",y,x);
return 0;
}
程序已運行過,不知道你有沒有其他要求,運行結果:
② 求高手們用C語言編寫一個函數,根據兩個變數自動顯示點的坐標(X,Y,Z)
//class是寫成類嗎,這個寫成類有點多此一舉,下面用最簡單的函數寫的,變數自己改成英文命名
1.h
#include<stdio.h>
#include<math.h>
//宏定義值
#definehXX
#defineLXX
#defineαXX
doubleβ,θ;
doubleA[3],B[3],M[3];
voidmath(β,θ,A,B,M);
1.cpp
#include"1.h"
math(β,θ,A,B,M)
{
A[0]=L*sin(fabs(θ-α));
A[1]=L*cos(fabs(θ-α))*cosβ;
A[2]=L*cos(fabs(θ-α))*sinβ,
//公式太長自己寫
}
voidmain()
{
printf("請輸入β,θ的值: ");
scanf("%f,%f",&β,&θ);
math(β,θ,A,B,M);
printf("A的坐標為:(%f,%f,%f) ",A[0],A[1],A[2]);
//輸出自己寫
}
③ 在c語言編程中怎樣編液晶屏顯示行走坐標
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int midx, midy; //定義坐標
initgraph(&gdriver, &gmode, "");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
midx = 200;
midy = 200;
setcolor(getmaxcolor());
getch();
closegraph();
return 0;
}
這個程序就是把坐標定義在了你屏幕上的(200,200),但是運行你看不出什麼來,現在我們加點東西就可以表現出來:
int midx, midy; 的後面加上int radius = 100;
setcolor(getmaxcolor()); 的後面加上circle(midx, midy, radius);
運行的結果就是以(200,200)為圓心做了半徑為100的圓
④ c語言中若要輸入坐標應該怎麼辦
先算出縱坐標的值,然後
用二維數組來存儲坐標,如:int a[5][5]; 可以用a[0][0] a[0][1]....
a[i][j]....a[4][3] a[4][4],來存儲5對坐標值,i、j分別是橫坐標和縱坐標。
⑤ c語言:編寫一個c程序,輸入兩點坐標,求這兩點的距離
聲明x1、y1、x2、y2浮點型變數為點p1和p2的座標,輸入數值後直接由公式√(x1-x2)^2+(y1-y2)^2求出。代碼如下:
#include"stdio.h"
#include"math.h"//調用sqrt需要包含此文件
intmain(intargc,char*argv[]){
doublex1,y1,x2,y2;
printf("... ");
scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);//輸入點座標
printf("Thedistance(p1(%g,%g)top2(%g,%g))is",x1,y1,x2,y2);
printf("%g ",sqrt((x1-=x2)*x1+(y1-=y2)*y1));//直接用公式求結果
return0;
}
運行樣例如下:
⑥ c語言中怎樣輸入三點坐標使它們不在同一行
先輸入兩個點,得出過這兩個點的直線公式,第三個點保證不在前兩個點構成的直線上即可。
⑦ C語言,任意輸入兩點坐標,輸出由該兩點構成的線段中點坐標,並說明
#include<stdio.h>
int main()
{float x1,y1,x2,y2,x,y;
scanf("%f%f%f%f",&x1,&y1,&x2,&y2);
x=(x1+x2)/2;
y=(y1+y2)/2;
printf("中點坐標:(%f,%f) ",x,y);
if(x==0)printf("在Y軸上 ");
else if(y==0)printf("在X軸上 ");
else if(x>0)
if(y>0)printf("在第I象限 ");
else printf("在第IV象限 ");
else
if(y>0)printf("在第II象限 ");
else printf("在第III象限 ");
return 0;
}
⑧ c語言程序設計,輸入一個點的坐標,輸出沿原點逆時針旋轉90度得到的坐標
坐標(x, y)沿原點逆時針旋轉90°後不就是(-y, x)嗎
⑨ c語言編程,輸入坐標,顯示所在坐標
intp_x=0,p_y=0;
printf("pleasetypeinthelocation,like3,4:");
scanf("%d,%d",&p_x,&p_y);
printf("thelocationis:(%d,%d)",p_x,p_y);
⑩ C語言兩點距離 輸入兩點坐標(X1,Y1),(X2,Y2)(0<=x1,x2,y1,y
您好,對於你的遇到的問題,我很高興能為你提供幫助,我之前也遇到過喲,以下是我的個人看法,希望能幫助到你,若有錯誤,還望見諒!。#include<iostream.h>
#include<math.h>
void main()
{
double x1,x2,y1,y2;
cout << "x1="; cin >> x1;
cout << "x2="; cin >> x2;
cout << "y1="; cin >> y1;
cout << "y2="; cin >> y2; //輸入坐標
double l = sqrt((y1 - x1) * (y1 - x1) + (y2 - x2) * (y2 - x2)); //計算結果
cout<<"兩點間距離為"<<l<<endl; //輸出結果
}非常感謝您的耐心觀看,如有幫助請採納,祝生活愉快!謝謝!