#include <stdio.h>
#include <windows.h>
#define N 20
void sjxsb(float,float,float);//此函数用于判断三角形的类型
/*此结构用于存放三角形的三边*/
struct sjx
{
float bian[3];//存放三角形的三条边
};
void main()
{
struct sjx sjx1[N];
int i,num;
printf("\n请输入您要判断的三角形的个数:");
scanf("%d",&num);
for (i=0;i<num;i++)
{
printf("\n请输入三角形的三边,用空格隔开:");
scanf("%f %f %f",&sjx1.bian[0],&sjx1.bian[1],&sjx1.bian[2]);
sjxsb(sjx1.bian[0],sjx1.bian[1],sjx1.bian[2]);
system("pause");
}
}
void sjxsb(float a,float b,float c)//此函数用于判断三角形的类型
{
if(a==b && b==c)
printf("\n该三角形为等边三角形\n\n");
else if(a==b || a==c || b==c)
printf("\n该三角形为等腰三角形\n\n");
else
printf("\n该三角形不是等边三角形\n\n");
}
我用工具检测结果:
--------------------Configuration: cx - Win32 Debug--------------------
Compiling...
cx.cpp
c:\documents and settings\administrator\桌面\cx.cpp(23) : error C2228: left of '.bian' must have class/struct/union type
c:\documents and settings\administrator\桌面\cx.cpp(23) : error C2228: left of '.bian' must have class/struct/union type
c:\documents and settings\administrator\桌面\cx.cpp(23) : error C2228: left of '.bian' must have class/struct/union type
c:\documents and settings\administrator\桌面\cx.cpp(25) : error C2228: left of '.bian' must have class/struct/union type
c:\documents and settings\administrator\桌面\cx.cpp(25) : error C2228: left of '.bian' must have class/struct/union type
c:\documents and settings\administrator\桌面\cx.cpp(25) : error C2228: left of '.bian' must have class/struct/union type
执行 cl.exe 时出错.
cx.obj - 1 error(s), 0 warning(s)