程序遇到无效指令并关闭 ?
#include<stdio.h>#include<math.h>
void main()
{
float *x, *y;
void change(float *x, float *y);
printf("input x,y:\n");scanf("%f%f", x, y);
change(x, y);
printf("%f,%f", *x, *y);
}
void change(float *x,float *y)
{
float s=*x, p=*y;
s = pow((s) * (s) + (p) * (p), 1.0 / 2);
//p = pow(tan((p) / (s)), -1);
p=tan(p/s);
p=p/1;
*x = s;*y = p;
}
----------------解决方案--------------------------------------------------------
定义时这样 float a,b,*x=&a,*y=&b;
或者
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
float x,y;
void change(float *, float *);
printf("input x,y:\n");
scanf("%f%f",&x,&y);
change(&x,&y);
printf("%f\t%f\n",x,y);
system("pause");
return 0;
}
void change(float *x,float *y)
{
float s=*x,p=*y;
s=pow((s)*(s)+(p)*(p),1.0/2);
p=tan(p/s);
p=p/1;
*x=s;
*y=p;
}
----------------解决方案--------------------------------------------------------
这个没有无效关闭
#include<stdio.h>#include<math.h>
void main()
{
float *x,*y;
float a,b;
void change(float *x,float *y);
x=&a;
y=&b;
printf("input x,y:\n");
scanf("%f%f",&a,&b);
change(&a,&b);
printf("%f,%f",*x,*y);
}
void change(float *x,float *y)
{
float s=*x, p=*y;
s = pow((s) * (s) + (p) * (p), 1.0 / 2);
/*/p = pow(tan((p) / (s)), -1);*/
p=tan(p/s);
p=p/1;
*x = s;*y = p;
}
----------------解决方案--------------------------------------------------------