新手求助,帮忙改下错
#include "graphics.h"#include "math.h"
#include "dos.h"
#include "conio.h"
#include "stdlib.h"
#include "stdio.h"
#include "stdarg.h"
#define maxpts 15
#define pi 3.1415926
struct pts {
int x, y;
};
double aspectratio = 0.85;
void linetodemo(void)
{
typedef struct viewporttype vp;
struct pts points[maxpts];
int i, j, h, w, xcenter, ycenter;
int radius, angle, step;
double rads;
printf(" moveto / lineto demonstration");
getviewsettings(&vp);
h = vp.bottom - vp.top;
w = vp.right - vp.left;
xcenter = w / 2; /* determine the center of circle */
ycenter = h / 2;
radius = (h - 30) / (aspectratio * 2);
step = 360 / maxpts; /* determine # of increments */
angle = 0; /* begin at zero degrees */
for (i = 0; irads = (double)angle * pi / 180.0; /* convert angle to radians */
points[i].x = xcenter + (int)(cos(rads) * radius);
points[i].y = ycenter - (int)(sin(rads) * radius * aspectratio);
angle += step; /* move to next increment */
}
circle(xcenter, ycenter, radius); /* draw bounding circle */
for (i = 0; ifor(j = i; jmoveto(points[i].x, points[i].y); /* move to beginning of cord */
lineto(points[j].x, points[j].y); /* draw the cord */
main()
{
int driver, mode;
driver = cga; mode = cgac0;
initgraph(&driver, &mode, "");
setcolor(3);
setbkcolor(green);
linetodemo();
}
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(22): error C2275: “vp”: 将此类型用作表达式非法
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(16): note: 参见“vp”的声明
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(22): error C3861: “getviewsettings”: 找不到标识符
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(23): error C2027: 使用了未定义类型“linetodemo::viewporttype”
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(16): note: 参见“linetodemo::viewporttype”的声明
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(23): error C2228: “.bottom”的左边必须有类/结构/联合
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(23): error C2228: “.top”的左边必须有类/结构/联合
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(24): error C2027: 使用了未定义类型“linetodemo::viewporttype”
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(16): note: 参见“linetodemo::viewporttype”的声明
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(24): error C2228: “.right”的左边必须有类/结构/联合
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(24): error C2228: “.left”的左边必须有类/结构/联合
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(27): warning C4244: “=”: 从“double”转换到“int”,可能丢失数据
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(30): error C2065: “irads”: 未声明的标识符
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(32): error C2146: 语法错误: 缺少“)”(在标识符“points”的前面)
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(32): error C2059: 语法错误:“;”
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(35): error C2065: “xcenter”: 未声明的标识符
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(35): error C2065: “ycenter”: 未声明的标识符
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(35): error C2065: “radius”: 未声明的标识符
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(35): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(35): error C2365: “circle”: 重定义;以前的定义是“函数”
1>d:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.10.25017\include\easyx.h(195): note: 参见“circle”的声明
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(36): error C2059: 语法错误:“for”
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(36): error C2143: 语法错误: 缺少“)”(在“;”的前面)
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(36): error C2065: “j”: 未声明的标识符
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(36): error C2065: “i”: 未声明的标识符
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(36): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(36): error C2065: “points”: 未声明的标识符
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(36): error C2228: “.x”的左边必须有类/结构/联合
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(36): error C2228: “.y”的左边必须有类/结构/联合
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(37): error C2065: “points”: 未声明的标识符
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(37): error C2065: “j”: 未声明的标识符
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(37): error C2228: “.x”的左边必须有类/结构/联合
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(37): error C2228: “.y”的左边必须有类/结构/联合
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(37): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(37): error C2365: “lineto”: 重定义;以前的定义是“函数”
1>d:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.10.25017\include\easyx.h(188): note: 参见“lineto”的声明
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(40): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(42): error C2065: “cga”: 未声明的标识符
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(42): error C2065: “cgac0”: 未声明的标识符
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(45): error C2065: “green”: 未声明的标识符
1>已完成生成项目“ConsoleApplication1.vcxproj”的操作 - 失败。
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========