标题:新手求助,帮忙改下错
只看楼主
我是个宝宝
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2017-6-12
结帖率:100%
已结贴  问题点数:20 回复次数:10 
新手求助,帮忙改下错
#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
renkejun1942
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:不是这样
等 级:贵宾
威 望:33
帖 子:1645
专家分:5297
注 册:2016-12-1
得分: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);//错误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; irads = (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; 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();
}

09:30 05/21 种下琵琶种子,能种活么?等待中……
21:50 05/27 没有发芽。
20:51 05/28 没有发芽。
23:03 05/29 没有发芽。
23:30 06/09 我有预感,要发芽了。
2017-06-13 04:47
我是个宝宝
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
renkejun1942
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:不是这样
等 级:贵宾
威 望:33
帖 子:1645
专家分:5297
注 册:2016-12-1
得分:6 
我用手机,哪能看的那么细致,我每天用电脑的时间也就两到三个小时,如果都去帮别人修改错误,我自己怎么继续自学编程。

你的代码不改也罢,原因在于你根本没有系统的学过C,这是看你的代码时我的体会,所以你现在的主要问题不是修改你现在的代码,而是系统的学习C的基础知识,否则你的代码的任何问题你都解决不了,难道你要衣靠别人一辈子?

09:30 05/21 种下琵琶种子,能种活么?等待中……
21:50 05/27 没有发芽。
20:51 05/28 没有发芽。
23:03 05/29 没有发芽。
23:30 06/09 我有预感,要发芽了。
2017-06-13 14:03
wp231957
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:神界
等 级:版主
威 望:422
帖 子:13681
专家分:53296
注 册:2012-10-18
得分:8 
你这个代码基本可以断定是TC下的代码  TC对于现代来说 有些太原始了  所以他下面的东东
无法全部移植到现代  如果你想实现类似功能 有些连借鉴都办不到  只能从头自己写

DO IT YOURSELF !
2017-06-13 16:04



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-477862-1-1.html




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

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