① 編程 輸入一平面坐標點(x,y),判斷並輸出該坐標點位於哪個象限c語言
#include<stdio.h>
int x,y;
char *output[20];
int p;
void main(){
printf("請輸入一個坐標如:3,3\n");
while(scanf("%d,%d",&x,&y)!=EOF)
{
if(x > 0 && y > 0)
p=1;
else if(x > 0 && y < 0)
p=4;
else if(x < 0 && y > 0)
p=2;
else if(x < 0 && y < 0)
p=3;
switch(p){
case 1:*output = "第一象限\n";break;
case 4:*output = "第四象限\n";break;
case 2:*output = "第二象限\n";break;
case 3:*output = "第三象限\n";break;
}
printf("%s",*output);
}
}
② 數控中加工坐標YBC中"Y","B","C"分別指的是什麼
這是數控彎管運動指令的位置指令。
③ (用c++編寫程序)輸入平面直角坐標系中一點的坐標(x,y),判斷改點是在那個象限中或那一條坐標軸上
include "math.h"
class point
{
public:
float x;
float y;
//構造函數
point(float x,float y)
{
this->x=x;
this->y=y;
}
};
class line
{
float a;
float b;
float c;
public:
//構造函數
line(float a,float b,float c)
{
this->a=a;
this->b=b;
this->c=c;
}
float getDistance(point p)
{
float x,y;
x=p.x;
y=p.y;
return fabs(a*x+b*y+c)/sqrt(a*a+b*b);
}
};
void main()
{
float x,y;
cout<<"請輸入點的X坐標:";
cin>>x;
cout<<"請輸入點的Y坐標:";
cin>>y;
point p(x,y);
float a,b,c;
cout<<"請輸入a:";
cin>>a;
cout<<"請輸入b:";
cin>>b;
cout<<"請輸入c:";
cin>>c;
line l(a,b,c);
cout<<"點到直線的距離為:"<<l.getDistance(p)<<endl;
}