用VC单文档编了一个分类的程序,想在我自定义的类中的函数里调用textout,可以再指定的坐标处显示相应数
总是出现一个错误errorC2660:'GetDC':functiondoesnottake0parameters下面是主要的算法程序:voidCAntCluster::...
总是出现一个错误
error C2660: 'GetDC' : function does not take 0 parameters
下面是主要的算法程序:
void CAntCluster::ClusterProc(int m_nThreshold,int m_nAntNumber,int m_nSpawnNumber,int m_nCirculationNum)
{
FILE *fp;
int sum;
sum=m_nAntNumber+m_nSpawnNumber;
struct spawn parray[60];
struct ant qarray[10];
int i,j,c;
int b[10];
CString str;
CDC *pDC=GetDC();
for(i=0;i<m_nAntNumber;i++)
b[i]=0;
fp=fopen("1.txt","r");
for(i=0;i<sum;i++)
{
fscanf(fp,"%d,%d%",parray[i].Coordinate_X,parray[i].Coordinate_Y);
parray[i].spawnclass=0;
}
fclose(fp);
for(i=m_nSpawnNumber;i<sum;i++)
{
qarray[i-m_nSpawnNumber].Coordinate_X=parray[i].Coordinate_X;
qarray[i-m_nSpawnNumber].Coordinate_Y=parray[i].Coordinate_Y;
}
double a[60][60];
for(i=0;i<m_nSpawnNumber;i++)
{
for(j=i+1;j<m_nSpawnNumber;j++)
if(sqrt((parray[i].Coordinate_X-parray[j].Coordinate_X)*(parray[i].Coordinate_X-parray[j].Coordinate_X)+(parray[i].Coordinate_X-parray[j].Coordinate_X)*(parray[i].Coordinate_Y-parray[j].Coordinate_Y))<=m_nThreshold)
a[i][j]=1;
else a[i][j]=0;
}
// for(i=0;i<50;i++)
// if(parray[i].spawnclass!=0) break;
srand((unsigned)time(NULL));
for(i=0;i<m_nAntNumber;i++)
{
int RandData = rand() ; //生成0~m_nSpawnNumber-1之间的随机数
RandData %= m_nSpawnNumber;//m_nSpawnNumber;
qarray[i].Coordinate_X=parray[RandData].Coordinate_X;
qarray[i].Coordinate_Y=parray[RandData].Coordinate_Y;
parray[i].spawnclass=i-m_nSpawnNumber+1;
b[i]=RandData;
c++;
}//蚂蚁随机移动到五个蚁卵处
lop:for(i=0;i<m_nAntNumber;i++)
{
loop: int RandData = rand() ; //生成0~m_nSpawnNumber-1之间的随机数
RandData %= m_nSpawnNumber;
if(parray[RandData].spawnclass==0)
{
if(a[RandData][b[i]]==1)
{
parray[RandData].spawnclass=parray[b[i]].spawnclass;//标记与上一点同类
}
else
{
loop1: int RandData1=rand();
RandData1%=m_nSpawnNumber;
while(a[RandData][RandData1]!=1) goto loop1;
if(parray[RandData1].spawnclass=!0)
parray[RandData].spawnclass=parray[RandData1].spawnclass;
else
{
while(j<m_nCirculationNum)
{
j++;
goto loop1;
}
parray[RandData].spawnclass=++c;
}
}
qarray[i].Coordinate_X=parray[RandData].Coordinate_X;
qarray[i].Coordinate_Y=parray[RandData].Coordinate_Y;
b[i]=RandData;
}
else
goto loop;
}
for(i=0;i<m_nSpawnNumber;i++)
if (parray[i].spawnclass==0) goto lop;
for(i=0;i<m_nSpawnNumber;i++)
{
str.Format("%d",parray[i].spawnclass);
pDC->TextOut(parray[i].Coordinate_X,parray[i].Coordinate_Y,str);
}
}
没有币来悬赏了,请大家见谅,明天要交作业了,希望能者多多帮忙,谢过大家了! 展开
error C2660: 'GetDC' : function does not take 0 parameters
下面是主要的算法程序:
void CAntCluster::ClusterProc(int m_nThreshold,int m_nAntNumber,int m_nSpawnNumber,int m_nCirculationNum)
{
FILE *fp;
int sum;
sum=m_nAntNumber+m_nSpawnNumber;
struct spawn parray[60];
struct ant qarray[10];
int i,j,c;
int b[10];
CString str;
CDC *pDC=GetDC();
for(i=0;i<m_nAntNumber;i++)
b[i]=0;
fp=fopen("1.txt","r");
for(i=0;i<sum;i++)
{
fscanf(fp,"%d,%d%",parray[i].Coordinate_X,parray[i].Coordinate_Y);
parray[i].spawnclass=0;
}
fclose(fp);
for(i=m_nSpawnNumber;i<sum;i++)
{
qarray[i-m_nSpawnNumber].Coordinate_X=parray[i].Coordinate_X;
qarray[i-m_nSpawnNumber].Coordinate_Y=parray[i].Coordinate_Y;
}
double a[60][60];
for(i=0;i<m_nSpawnNumber;i++)
{
for(j=i+1;j<m_nSpawnNumber;j++)
if(sqrt((parray[i].Coordinate_X-parray[j].Coordinate_X)*(parray[i].Coordinate_X-parray[j].Coordinate_X)+(parray[i].Coordinate_X-parray[j].Coordinate_X)*(parray[i].Coordinate_Y-parray[j].Coordinate_Y))<=m_nThreshold)
a[i][j]=1;
else a[i][j]=0;
}
// for(i=0;i<50;i++)
// if(parray[i].spawnclass!=0) break;
srand((unsigned)time(NULL));
for(i=0;i<m_nAntNumber;i++)
{
int RandData = rand() ; //生成0~m_nSpawnNumber-1之间的随机数
RandData %= m_nSpawnNumber;//m_nSpawnNumber;
qarray[i].Coordinate_X=parray[RandData].Coordinate_X;
qarray[i].Coordinate_Y=parray[RandData].Coordinate_Y;
parray[i].spawnclass=i-m_nSpawnNumber+1;
b[i]=RandData;
c++;
}//蚂蚁随机移动到五个蚁卵处
lop:for(i=0;i<m_nAntNumber;i++)
{
loop: int RandData = rand() ; //生成0~m_nSpawnNumber-1之间的随机数
RandData %= m_nSpawnNumber;
if(parray[RandData].spawnclass==0)
{
if(a[RandData][b[i]]==1)
{
parray[RandData].spawnclass=parray[b[i]].spawnclass;//标记与上一点同类
}
else
{
loop1: int RandData1=rand();
RandData1%=m_nSpawnNumber;
while(a[RandData][RandData1]!=1) goto loop1;
if(parray[RandData1].spawnclass=!0)
parray[RandData].spawnclass=parray[RandData1].spawnclass;
else
{
while(j<m_nCirculationNum)
{
j++;
goto loop1;
}
parray[RandData].spawnclass=++c;
}
}
qarray[i].Coordinate_X=parray[RandData].Coordinate_X;
qarray[i].Coordinate_Y=parray[RandData].Coordinate_Y;
b[i]=RandData;
}
else
goto loop;
}
for(i=0;i<m_nSpawnNumber;i++)
if (parray[i].spawnclass==0) goto lop;
for(i=0;i<m_nSpawnNumber;i++)
{
str.Format("%d",parray[i].spawnclass);
pDC->TextOut(parray[i].Coordinate_X,parray[i].Coordinate_Y,str);
}
}
没有币来悬赏了,请大家见谅,明天要交作业了,希望能者多多帮忙,谢过大家了! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询