帮我看看这段代码有什么问题?

golden_alvin 2004-09-19 09:03:28
double PP1[8][8];
double PP2[8][8];

double x;
double n;
double d;
for(double i = 0; i < 8; i++)
{
n = i + 1;
d = n / (n * (n - 1) - (n - 2) * (n - 3) / 2);
x = (n - 1) * d;
for(double k = 0; k < i ; k++)
{
PP1[i][k] = x - k * d;
}
PP1[i][i] = x;
}
有六个错误:
e:\documents and settings\administrator\my documents\map\main.cpp(77) : error C2108: subscript is not of integral type
e:\documents and settings\administrator\my documents\map\main.cpp(77) : error C2108: subscript is not of integral type
e:\documents and settings\administrator\my documents\map\main.cpp(77) : error C2440: '=' : cannot convert from 'double' to 'double (*)[8]'
There is no context in which this conversion is possible
e:\documents and settings\administrator\my documents\map\main.cpp(79) : error C2108: subscript is not of integral type
e:\documents and settings\administrator\my documents\map\main.cpp(79) : error C2108: subscript is not of integral type
e:\documents and settings\administrator\my documents\map\main.cpp(79) : error C2440: '=' : cannot convert from 'double' to 'double (*)[8]'
There is no context in which this conversion is possible
怎么回事啊?
...全文
227 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
菲斯可儿 2004-09-19
  • 打赏
  • 举报
回复
楼上说的对~
brapler 2004-09-19
  • 打赏
  • 举报
回复
数组下标要用整形,要么把k,i之类的声明成整形,要么做过强制转换一下。
roger_ding 2004-09-19
  • 打赏
  • 举报
回复
在CSDN论坛上搜索“提问”,如果你视力没到1000的话
iceeleca 2004-09-19
  • 打赏
  • 举报
回复
哥哥呀,怎么发贴子呀?我是新注册的,不知道,请帮忙!
roger_ding 2004-09-19
  • 打赏
  • 举报
回复
指明了是77、79行的错误,自己找吧

Compiler Error C2108
subscript is not of integral type
A nonintegral expression was used in an array subscript


Compiler Error C2440
'conversion' : cannot convert from 'type1' to 'type2'

The compiler was unable to cast from ‘type1’ to ‘type2.’ If you’ve encountered this error on code which compiled with an earlier version of Visual C++, please read Technote: Improved Conformance to ANSI C++ for more information.

The following example illustrates this error.

void main()
{


int *i;
float j;

j = (float)i; /* cannot cast from
pointer to int to float */


}


16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧