
C语言结构体报错,但是我感觉没错而且作为c++程序能够运行
直接上程序/****************************************任务:结构体——计算点到直线的距离时间:2015年6月23日22:19:15*...
直接上程序
/****************************************
任务:结构体——计算点到直线的距离
时间:2015年6月23日22:19:15
******************************************/
# include <stdio.h>
# include <math.h>
struct Line /* ax+by+c=0 */
{
float a;
float b;
float c;
}L; // 12行
struct Point
{
float x;
float y;
}P;
float pToL( Line A,Point B)
{
return fabs(A.a*B.x+A.b*B.y+A.c)rt(A.a*A.a+A.b*A.b);
}
int main(void)
{
float m;
printf("请输入点坐标(横纵逗号隔开):");
scanf("%f,%f",&P.x,&P.y);
printf("请按顺序输入直线的A、B、C逗号隔开(Ax+By+C=0):",&L.a,&L.b,&L.c);
scanf("%f,%f,%f",&L.a,&L.b,&L.c);
m=pToL(L,P);
printf("点到直线的距离为:%f",m);
return 0;
}
报错:
错误 1 error C2146: 语法错误: 缺少“)”(在标识符“a”的前面)
错误 2 error C2061: 语法错误: 标识符“a”
错误 3 error C2059: 语法错误:“;”
错误 4 error C2059: 语法错误:“,”
错误 5 error C2059: 语法错误:“)” c:\users\administrator\desktop\consoleapplication2\consoleapplication2\源.c 12
以上错误均为12行报错
注: .cpp文件能够编译成功 展开
/****************************************
任务:结构体——计算点到直线的距离
时间:2015年6月23日22:19:15
******************************************/
# include <stdio.h>
# include <math.h>
struct Line /* ax+by+c=0 */
{
float a;
float b;
float c;
}L; // 12行
struct Point
{
float x;
float y;
}P;
float pToL( Line A,Point B)
{
return fabs(A.a*B.x+A.b*B.y+A.c)rt(A.a*A.a+A.b*A.b);
}
int main(void)
{
float m;
printf("请输入点坐标(横纵逗号隔开):");
scanf("%f,%f",&P.x,&P.y);
printf("请按顺序输入直线的A、B、C逗号隔开(Ax+By+C=0):",&L.a,&L.b,&L.c);
scanf("%f,%f,%f",&L.a,&L.b,&L.c);
m=pToL(L,P);
printf("点到直线的距离为:%f",m);
return 0;
}
报错:
错误 1 error C2146: 语法错误: 缺少“)”(在标识符“a”的前面)
错误 2 error C2061: 语法错误: 标识符“a”
错误 3 error C2059: 语法错误:“;”
错误 4 error C2059: 语法错误:“,”
错误 5 error C2059: 语法错误:“)” c:\users\administrator\desktop\consoleapplication2\consoleapplication2\源.c 12
以上错误均为12行报错
注: .cpp文件能够编译成功 展开
1个回答
展开全部
#define NULL 0;
#include<malloc.h>
#include<stdio.h>
struct student
{int num;
int score;
struct student *next;
};
int n;
struct student *creat(void)
{ struct student *head;
struct student *p1,*p2;
p1=p2=(struct student *)malloc(sizeof(struct student));
head=p1;
scanf("%d,%d",&p1->num,&p1->score);
for(n=0; p1->num!=0; ++n)
{
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询