#include <cmath>
const int SIZE=8;
const double PI=3.1415926;int main()
{
float DctPara[SIZE][SIZE];
unsigned char Data[SIZE][SIZE]={{124,123,122,121,120,119,118,117},
{21,22,23,24,25,26,27,28},
{54,55,56,57,58,59,60,61},
{12,13,14,15,16,17,18,19},
{233,234,235,236,237,238,239,240},
{222,223,224,225,226,227,228,229},
{1,2,3,4,5,6,7,8},
{141,142,143,144,145,146,147,148}};
int i,j;
float temp[SIZE];
float *p;
float *dct(float Row[SIZE],int N);
float cp(int u);
for(i=0;i<SIZE;i++)
{
for(j=0;j<SIZE;j++)
temp[j]=Data[i][j];
p=dct(temp,SIZE);
for(j=0;j<SIZE;j++,p++)
DctPara[i][j]=*p;
}
for(j=0;j<SIZE;j++)
{
for(i=0;i<SIZE;i++)
temp[i]=DctPara[i][j];
p=dct(temp,SIZE);
for(i=0;i<SIZE;i++,p++)
DctPara[i][j]=*p;
}
float *dct(float Row[SIZE],int N)
{
int x;
int u;
float t=0;
float *temp1=new float[N];
for (u=0;u<N;u++)
{
for (x=0;x<N;x++)
t+=Row[x]*cos((2*x+1)*u*pi/2/N);
temp1[u]=t*cp(u)*sqrt(2.0/N);
t=0;
}
return temp1;
}
float cp(int u)
{
float x;
if (u==0)
x=1.0/sqrt(2);
else
x=1;
return x;
}
return 0;
}
Compiling...
dct.cpp
D:\programming\dct.cpp(45) : error C2601: 'dct' : local function definitions are illegal
D:\programming\dct.cpp(62) : error C2601: 'cp' : local function definitions are illegal
Error executing cl.exe.dct.obj - 2 error(s), 0 warning(s)
谢谢
const int SIZE=8;
const double PI=3.1415926;int main()
{
float DctPara[SIZE][SIZE];
unsigned char Data[SIZE][SIZE]={{124,123,122,121,120,119,118,117},
{21,22,23,24,25,26,27,28},
{54,55,56,57,58,59,60,61},
{12,13,14,15,16,17,18,19},
{233,234,235,236,237,238,239,240},
{222,223,224,225,226,227,228,229},
{1,2,3,4,5,6,7,8},
{141,142,143,144,145,146,147,148}};
int i,j;
float temp[SIZE];
float *p;
float *dct(float Row[SIZE],int N);
float cp(int u);
for(i=0;i<SIZE;i++)
{
for(j=0;j<SIZE;j++)
temp[j]=Data[i][j];
p=dct(temp,SIZE);
for(j=0;j<SIZE;j++,p++)
DctPara[i][j]=*p;
}
for(j=0;j<SIZE;j++)
{
for(i=0;i<SIZE;i++)
temp[i]=DctPara[i][j];
p=dct(temp,SIZE);
for(i=0;i<SIZE;i++,p++)
DctPara[i][j]=*p;
}
float *dct(float Row[SIZE],int N)
{
int x;
int u;
float t=0;
float *temp1=new float[N];
for (u=0;u<N;u++)
{
for (x=0;x<N;x++)
t+=Row[x]*cos((2*x+1)*u*pi/2/N);
temp1[u]=t*cp(u)*sqrt(2.0/N);
t=0;
}
return temp1;
}
float cp(int u)
{
float x;
if (u==0)
x=1.0/sqrt(2);
else
x=1;
return x;
}
return 0;
}
Compiling...
dct.cpp
D:\programming\dct.cpp(45) : error C2601: 'dct' : local function definitions are illegal
D:\programming\dct.cpp(62) : error C2601: 'cp' : local function definitions are illegal
Error executing cl.exe.dct.obj - 2 error(s), 0 warning(s)
谢谢
解决方案 »
- 树形控件设置如何复选?
- 谁能帮忙看下为什么编译出错?
- 怎样在VC中读取EXCEL里的数据。。帮帮忙啊!100分奉上
- 请问如何在WIN2000下用VC6访问任意4字节地址的数据(在线等待)?
- 100分求教一具有挑战性的函数调试问题
- 初学数据库编程,有个简单问题
- 我已經好頭痛了....請知深的朋友來回答:
- 初學者,該學vc 還是c++.請高手指點迷津.
- 一个奇怪的绘图程序
- 我用MCIWNDCREATE()和MCIWNDPLAY播放AVI不知怎样结束?用MCIWNDPLAYTO和MCIWNDSEEK俩函数不行?
- 请教高手,使用ListCtrl控件,如何把滚动条滚动到最后一行
- 问个很弱的问题,0x0000001FL
是函数写在别的函数体内
float cp(int u);
这两句放到main()上边
/////////////////////////////////////////////////
float *dct(float Row[SIZE],int N);
float cp(int u);
void mian()
{
}