作业帮 > 综合 > 作业

编程 输入一平面坐标点(x,y),判断并输出该坐标点位于哪个象限?c语言

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/14 08:41:02
编程 输入一平面坐标点(x,y),判断并输出该坐标点位于哪个象限?c语言
#include
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);
}
}