注册 登录
编程论坛 C++教室

很菜很菜的菜鸟急需高手帮忙!!!!!!!!

young1988 发布于 2010-05-19 23:34, 383 次点击
#include"stdio.h"
#include"math.h"
void main()
{double p,q,m,t,x1,x2,w;
double y;
long double x;
printf ("请依次输入:刀齿半径,圆周线速度,机器前进速度,运行时间");
scanf("%f,%f,%f,%f",&p,&q,&m,&t);
if(q/m==1)printf("标准摆线");
else if (q/m<1)printf("长辐摆线");
else if (q/m>1)printf("短辐摆线");
w=q/p;
printf("角速度为:%f\n",w);
y=w*t;
printf("角位移为:%f\n",y);
x1=m-q*cos(y);
x2=q*sin(y);
x=(x1)^2+(x2)^2;
printf("刀齿切削x方向分速度为:%f\n",x1);
printf("刀齿切削y方向分速度为:%f\n",x2);
printf("刀齿切削速度为:%f\n",x);
}试运行后显示error C2297: '%' : illegal, right operand has type 'double'请高手帮忙检查下  (cos函数里的只能定义double类型么?x定义long double不能运行时因为定义类型无法满足要求么?)
2 回复
#2
lijm19892010-05-20 08:07
x=(x1)^2+(x2)^2;
C语言中没有这种表达方式。
改为 : x = x1*x1 + x2*x2;
试试
#3
fanfan3202010-05-20 10:34
我也赞同上楼的,在C语言里没见过x=(x1)^2+(x2)^2的表达式
1