Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

小弟新手,弱弱的Compile Error 请教,谢谢!

Posted by eliteGoblin at 2011-02-15 12:53:15
Problem ID: 1226,我的代码在VS2008上运行通过,可是在这里怎么提交也是Compile error:
我的代码: 贴出来就是这德行,水平没有滚动条,有几行换行不正确,不知是否这样影响编译?

#include <stdio.h>
#include <string.h>

#define DIM2MAP(org,dim2,a,b) *((org)+(dim2)*(a)+(b))  
#define GRPDIM1 100
#define GRPDIM2 128

bool IsSubString(const char *szSrc,char *szSub);
int LenOfSubString(const char * grp,int ctStr);

void main(){
	int ctTestGrp,ctGrpString;
	char szStrGrp[GRPDIM1][GRPDIM2];

	scanf("%d",&ctTestGrp);

	for(;ctTestGrp>0;ctTestGrp--){
		scanf("%d",&ctGrpString);
		for(int i=0;i<ctGrpString;i++){
			scanf("%s",szStrGrp[i]);
		}
		printf("%d\n",LenOfSubString((const char *)szStrGrp,ctGrpString));
	}
}

bool IsSubString(const char *szSrc,char *szSub){
	if(strstr(szSrc,szSub)||
		strstr(szSrc,strrev(szSub)))
		return true;
	else
		return false;
}

int LenOfSubString(const char * grp,int ctStr){
	int nMaxLen=(ctStr==1)?(strlen(&DIM2MAP(grp,GRPDIM2,0,0))):0;
	for(int i=0;i<ctStr;i++){ 
		const char *p=&DIM2MAP(grp,GRPDIM2,i,0);
		int nMomLen=strlen(p);

		for(int j=0;j<nMomLen;j++){ 
			int nSubLen=1;
			bool bIsAllSub=true;

			for(;(j<=nMomLen-nSubLen)&& 
				bIsAllSub;){
					int k=0;
					bIsAllSub=true; 
					for(;k<ctStr;k++){ 
						if(k==i) continue;
						else{
							char szSubBuffer[GRPDIM2];
							strncpy_s(szSubBuffer,GRPDIM2,&p[j],nSubLen);
							if(!IsSubString(&DIM2MAP(grp,GRPDIM2,k,0),szSubBuffer)){ // if is not other's substring
								bIsAllSub=false;
								break;
							}
						}
					}
					if(k==ctStr){ 
						nMaxLen=nMaxLen>=nSubLen?nMaxLen:nSubLen;
						nSubLen++; 
					}
			}		
		}

	}
	return nMaxLen;
}





//以上代码完 *****************************************************

错误提示:我声明实现后的函数IsSubString被认为是syntax error : identifier 'IsSubString' ,不知为什么?


    * Compile Error

      Main.c
      Main.c(10) : error C2061: syntax error : identifier 'IsSubString'
      Main.c(10) : error C2059: syntax error : ';'
      Main.c(10) : error C2059: syntax error : 'type'
      Main.c(20) : error C2143: syntax error : missing ';' before 'type'
      Main.c(20) : error C2143: syntax error : missing ';' before 'type'
      Main.c(20) : error C2143: syntax error : missing ')' before 'type'
      Main.c(20) : error C2143: syntax error : missing ';' before 'type'
      Main.c(20) : error C2065: 'i' : undeclared identifier
      Main.c(20) : error C2065: 'i' : undeclared identifier
      Main.c(20) : error C2059: syntax error : ')'
      Main.c(20) : error C2143: syntax error : missing ';' before '{'
      Main.c(21) : error C2065: 'i' : undeclared identifier
      Main.c(24) : error C2143: syntax error : missing ';' before 'type'
      Main.c(24) : error C2143: syntax error : missing ';' before 'type'
      Main.c(24) : error C2143: syntax error : missing ')' before 'type'
      Main.c(24) : error C2143: syntax error : missing ';' before 'type'
      Main.c(24) : error C2065: 'j' : undeclared identifier
      Main.c(24) : error C2065: 'j' : undeclared identifier
      Main.c(24) : error C2059: syntax error : ')'
      Main.c(24) : error C2143: syntax error : missing ';' before '{'
      Main.c(26) : error C2065: 'bool' : undeclared identifier
      Main.c(26) : error C2146: syntax error : missing ';' before identifier 'bIsAllSub'
      Main.c(26) : error C2065: 'bIsAllSub' : undeclared identifier
      Main.c(26) : error C2065: 'true' : undeclared identifier
      Main.c(28) : error C2065: 'j' : undeclared identifier
      Main.c(29) : error C2065: 'bIsAllSub' : undeclared identifier
      Main.c(31) : error C2065: 'bIsAllSub' : undeclared identifier
      Main.c(31) : error C2065: 'true' : undeclared identifier
      Main.c(33) : error C2065: 'i' : undeclared identifier
      Main.c(37) : error C2065: 'j' : undeclared identifier
      Main.c(39) : error C2065: 'bIsAllSub' : undeclared identifier
      Main.c(39) : error C2065: 'false' : undeclared identifier
      Main.c(71) : error C2143: syntax error : missing ';' before 'type'
      Main.c(71) : error C2143: syntax error : missing ';' before 'type'
      Main.c(71) : error C2143: syntax error : missing ')' before 'type'
      Main.c(71) : error C2143: syntax error : missing ';' before 'type'
      Main.c(71) : error C2065: 'i' : undeclared identifier
      Main.c(71) : error C2065: 'i' : undeclared identifier
      Main.c(71) : error C2059: syntax error : ')'
      Main.c(71) : error C2143: syntax error : missing ';' before '{'
      Main.c(72) : error C2065: 'i' : undeclared identifier


谢谢大家! :)

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator