| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3408 人关注过本帖
标题:新手求助,帮忙改下错
取消只看楼主 加入收藏
我是个宝宝
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2017-6-12
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:6 
新手求助,帮忙改下错
#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 个 ==========
搜索更多相关主题的帖子: include double points angle 
2017-06-12 23:00
我是个宝宝
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2017-6-12
收藏
得分:0 
#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);//错误1
    h = vp.bottom - vp.top;//错误2
    w = vp.right - vp.left;//错误3
    xcenter = w / 2; /* determine the center of circle *///因为错误3,所以这里错误4
    ycenter = h / 2;//因为错误2,所以这里错误5
    radius = (h - 30) / (aspectratio * 2);
    step = 360 / maxpts; /* determine # of increments */
    angle = 0; /* begin at zero degrees */
    for (i = 0; i < maxpts; ++i) {
        rads = (double)angle * pi / 180.0;/* convert angle to radians *///for循环语法错误
        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; i < maxpts; ++j)
    {
        for (j = i; j < maxpts; ++j)
        {
            moveto(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(47): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(49): error C2065: “cga”: 未声明的标识符
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(49): error C2065: “cgac0”: 未声明的标识符
1>e:\作业\c语言\测试\consoleapplication1\consoleapplication1\源.cpp(52): error C2065: “green”: 未声明的标识符
1>已完成生成项目“ConsoleApplication1.vcxproj”的操作 - 失败。
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========

2017-06-13 10:03
我是个宝宝
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2017-6-12
收藏
得分:0 
typedef struct viewporttype vp;//这句有没有问题。
帮我改一下,这程序是运行库缺失吗?
2017-06-13 10:06
我是个宝宝
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2017-6-12
收藏
得分:0 
怎么用windows.h替换dos.h指令怎么改。

[此贴子已经被作者于2017-6-13 12:38编辑过]

2017-06-13 10:43
我是个宝宝
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2017-6-12
收藏
得分:0 
vc没有dos.h头文件,能用windows.h替换不?
2017-06-13 12:44
我是个宝宝
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2017-6-12
收藏
得分:0 
回复 2楼 renkejun1942
能不能再帮我看下,谢谢。
2017-06-13 12:45
我是个宝宝
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2017-6-12
收藏
得分:0 
回复 2楼 renkejun1942
能不能再帮我看下,谢谢。
2017-06-13 12:45
快速回复:新手求助,帮忙改下错
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028203 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved