第1个回答 2010-12-14
#include "stdafx.h"
#include "iostream.h"
#include "iomanip.h"
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
typedef int Status;
typedef struct OLNode{
int i,j;
int e;
struct OLNode *right,*down;
}OLNode, *OLink;
typedef struct{
OLink *rhead,*chead;
int mu,nu,tu;
}CrossList;
Status CreateSMatrix_OL(CrossList &M){
if(M) free(M);
scanf(&m,&n,&t);
M.mu:=m; M.nu=n; M.tu=t;
if(!(M.rhead=(OLink*)malloc((m+1)*sizeof(OLink))))exit(OVERFLOW);
if(!(M.chead=(OLink*)malloc((n+1)*sizeof(OLink))))exit(OVERFLOW);
M.rhead[]=M.chead[]=NULL;
for(scanf(&i,&j,&e);i!=0;scanf(&i,&j,&e)){
if(!(p=(OLNode*)malloc(sizeof(OLNode))))exit(OVERFLOW);
p->i=i;p->j=j;p->e=e;
if(M.rhead==NULL||M.rhead->j>j) {p->right=M.rhead;M.rhead=p;}
else{
for(q=M.rhead;(q->right)&&q->right->j<j;q=q->right);
p->right=q->right;q->right=p;
}
if(M.chead[j]==NULL||M.chead[j]->i>i){p->down=M.chead[j];M.chead[j]=p;}
else{
for(q=M.chead[j];(q->down)&&q->down->i<i;q=q->down);
p->down=q->down;q->down=p;
}
}
return OK;
}
return 0;
}
在"Status CreateSMatrix_OL(CrossList &M){ "出错:"error C2601: 'CreateSMatrix_OL' : local function definitions are illegal"
我检查过了,应该不是括号的匹配问题,顺便说下,我是在VC6.0中运行的..