㈠ c语言坐标函数用f吗
c语言坐标函数可以用f
1.编写程序,将直角坐标值转化为极坐标。极坐标的指哪公式是:
c= sqrt(x*x+y*y), 唯轮码q=arctan(y/x)
函数f的定义为:void fun(double x,double y,double *c,double *q),其中x, y为输入的直角坐标,指针c, q用于返回计算得到的桐做极坐标值。
主程序读入x, y,输出c, q,其中c,q保留小数点后面两位。
㈡ c语言 坐标
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int xmax, ymax;
initgraph(&gdriver, &gmode, ""); \*初试化图形*/
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n",
grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
setcolor(getmaxcolor()); \*可以选择颜色比如color(2)是一种颜色*/
xmax = getmaxx();
ymax = getmaxy();
line(0, 0, xmax, ymax);
getch();
closegraph();
return 0;
}
自己远行一下看看就明白了
㈢ 菜鸟求教C语言acos函数和坐标
acos(
)
的形参当然有范围,-1,至1,闭区间,基本的数学知识则神世,如果朝界控制台会显示-1.#IND,表示数据超界;关于坐瞎粗标的函数当然有,需要用到结构体COORD,以及头文件windows.h
具体代码如下:
#include
<windows.h>
#include
<stdio.h>孙肢
void
gotoxy(int
x,int
y)
{
COORD
coord;
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
void
main()
{
gotoxy(50,60);
printf("I
LOVE
YOU");
}
这个程序就实现了移动光标到指定位置,然后输出指定的内容。
㈣ C语言设计函数顶点坐标
参考代码如下:
函磨洞数头文件CalC.h
doublearround(doublex[],doubley[],intp);
函数定义文件CalC.c
#include<math.h>
doublearround(doublex[],doubley[],intp)
{
瞎段枯inti;
doubleC=0;//周长
doublel_p_i;//第i条边长度
for(i=0;i<p;i++)
{
燃好l_p_i=sqrt((y[i+1]-y[i])*(y[i+1]-y[i])+(x[i+1]-x[i])*(x[i+1]-x[i]));
printf("第%d条边长=%f ",i+1,l_p_i);
C+=l_p_i;
}
returnC;
}
主文件main.c
#include<stdio.h>
#include"CalC.h"
intmain(void)
{
doublex[3]={0.0,4.0,4.0};
doubley[3]={0.0,0.0,3.0};
intp=3;
doubleC=0.0;//周长
C=arround(x,y,p);
printf("C=%f ",C);
return0;
}
效果图
㈤ 求用c语言实现直角坐标(x,y,z)转换为球坐标(r,angle_a,angle_b),非常感谢
首先,matlab 本身提供了把直角坐标转化为极坐标的函数cart2pol。调用方法为:
[TH,R] = cart2pol(X,Y) TH 是极坐标的角度坐标,R 是距离坐标。
[TH,R,Z] = cart2pol(X,Y,Z) 这个函数同时支持3维直角坐标到柱坐标的转换。
如果因为是作业或者练习,一定要自己写一个的话,请继续往下看。
考虑到这个程序的性质,编成一个函数比较适合。编写这个函数需要用到直角坐标与极坐标的数学关系。考虑到世链输入参数可能是一个向量或矩阵如手,关系式里面的搜橡孙运算符应该用加点运算符。
函数代码如下:
function [ TH,R ] = mycart2pol(X,Y)
%this function transforms corresponding elements of data
%stored in Cartesian coordinates X,Y to polar coordinates
%angle TH and radius R.
R=(X.^2+Y.^2).^0.5;
TH=atan(Y./X);
end
测试结果如下:
㈥ 求高手们用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语言中若要输入坐标应该怎么办
先算出纵坐标的值,然后
用二维数组来存储坐标,如:int a[5][5]; 可以用a[0][0] a[0][1]....
a[i][j]....a[4][3] a[4][4],来存储5对坐标值,i、j分别是横坐标和纵坐标。
㈧ C语言里有没有可以获取特定颜色区域点的坐标的函数
c语言标准函数库里肯定是没有,c/c++界面开发工具QT,MFC估计会有
㈨ 用C语言编写一个程序:定义一个点的坐标,然后定义两个点,求这两个点间的距离。
#include<stdio.h>
#include<math.h>
structPoint
{
doublex,y;
};
/**.*/
doubledistance(conststructPoint*a,conststructPoint*b)
{
returnsqrt((a->x-b->x)*(a->x-b->x)+(a->y-b->y)*(a->y-b->y));
}
intmain()
{
structPointa,b;
printf("Pleaseinputthefirstpoint:");
scanf("%lf%lf",&a.x,&a.y);
printf("Pleaseinputthesecondpoint:");
scanf("%lf%lf",&b.x,&b.y);
printf("Thedistanceofthetwopointis%f. ",distance(&a,&b));
return0;
}
说明:
1、distance() 函数的两个参数 const struct Point *a 和 b 使用了 const 修饰,是表示 a 和 b 在函数执行过程中不会被修改;这样即使函数体内部写错,修改了 a 和 b 的值,编译也不会通过。
2、对 double,scanf 用 %lf,printf 用 %f。
以上。
㈩ 菜鸟求教C语言acos函数和坐标
acos( ) 的形参当然有范围,-1,至1,闭区间,基本的数学知识,如果朝界控制台会显示-1.#IND,表示数据超界;关于坐标的函数渣液当然有,需要用到结构体COORD,以慧友及头文件windows.h 具体代码如下:
#include <windows.h>
#include <stdio.h>
void gotoxy(int x,int y)
{
COORD coord;
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
void main()
{
gotoxy(50,60);
printf("I LOVE YOU");
}
这个程序就实现了移动光标到指前梁槐定位置,然后输出指定的内容。