将c ++代码转换为vb.net [英] convert c++ code into vb.net
本文介绍了将c ++代码转换为vb.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以将此 c ++代码转换为vb.net
Hi,
Can anyone convert this c++ code into vb.net
int check_definition(char *row,char *definition,char *map,char *seats,char *command,int *length,int *count)
{
int n,s,n1,n2,m,c,i;
char *p,*mb,mbuffer[256];
char *sb,sbuffer[2001];
char *cb,cbuffer[256];
n = 0;
s = 0;
mb = mbuffer;
sb = sbuffer;
cb = cbuffer;
while(*definition)
{
while(isspace(*definition))
++definition;
if(!definition[0])
break;
if(*definition == '+')
break;
if(*definition == ',')
{
++definition;
continue;
}
n1 = -1;
n2 = -1;
m = 0;
if(isdigit(*definition))
{
n1 = atoi(definition);
while(isdigit(*definition))
++definition;
while(isspace(*definition))
++definition;
}
if(*definition == '-')
{
if(n1 == -1)
return(-1);
++definition;
while(isspace(*definition))
++definition;
if(!isdigit(*definition))
return(-1);
n2 = atoi(definition);
while(isdigit(*definition))
++definition;
while(isspace(*definition))
++definition;
if(*definition && strchr("OE",toupper(*definition)))
{
m = toupper(*definition);
++definition;
}
while(isspace(*definition))
++definition;
}
if(n1 != -1)
{
if(n2 == -1)
{
++s;
*mb++ = 1;
sprintf(sb,"%d,",n1);
sb += strlen(sb);
if(n+s > 254)
return(-1);
}
else
{
c = n1;
while(1)
{
if(!m)
{
++s;
*mb++ = 1;
sprintf(sb,"%d,",c);
sb += strlen(sb);
}
else
{
if(m == 'E' && !(c & 1))
{
++s;
*mb++ = 1;
sprintf(sb,"%d,",c);
sb += strlen(sb);
}
if(m == 'O' && (c & 1))
{
++s;
*mb++ = 1;
sprintf(sb,"%d,",c);
sb += strlen(sb);
}
}
if(n+s > 254)
return(-1);
if(c == n2)
break;
if(n1 < n2)
++c;
else
--c;
}
}
continue;
}
if(*definition == '_')
{
*mb++ = 2;
++n;
++definition;
while(isspace(*definition))
++definition;
if(n+s > 254)
return(-1);
continue;
}
if(*definition == '!')
{
*mb++ = 3;
++n;
++definition;
while(isspace(*definition))
++definition;
if(n+s > 254)
return(-1);
continue;
}
if(*definition == '#')
{
*mb++ = 4;
n += 2;
++definition;
while(isspace(*definition))
++definition;
if(n+s > 254)
return(-1);
continue;
}
if(*definition == '$')
{
if(!row[0])
return(-1);
for(i = 0 ; row[i] ; i++)
{
++n;
*mb++ = row[i];
if(n+s > 254)
return(-1);
}
++definition;
while(isspace(*definition))
++definition;
continue;
}
if(*definition == 39)
{
p = strchr(definition+1,39);
if(!p)
return(-1);
++definition;
while(definition != p)
{
*mb++ = *definition++;
++n;
if(n+s > 254)
return(-1);
}
++definition;
while(isspace(*definition))
++definition;
continue;
}
return(-1);
}
while(*definition)
{
while(isspace(*definition))
++definition;
if(*definition == '+')
{
*cb++ = *definition++;
while(isspace(*definition))
++definition;
break;
}
return(-1);
}
if(*definition)
return(-1);
*mb = 0;
*sb = 0;
*cb = 0;
if(n+s > 254)
return(-1);
if(map)
strcpy(map,mbuffer);
if(seats)
strcpy(seats,sbuffer);
if(command)
strcpy(command,cbuffer);
if(length)
*length = n+s;
if(count)
*count = s;
return(0);
}
推荐答案
')
{
if (!row [ 0 ])
return ( -1);
for (i = 0 ; row [i]; i ++)
{
++ n;
* mb ++ = row [i];
if (n + s > 254 )
return ( - 1);
}
++定义;
while (isspace(* definition))
++ definition;
继续;
}
if (* definition == 39 )
{
p = strchr(定义+ 1, 39 );
if (!p)
return ( - 1);
++定义;
while (定义!= p)
{
* mb ++ = * definition ++;
++ n;
if (n + s > 254 )
return ( - 1);
}
++定义;
while (isspace(* definition))
++ definition;
继续;
}
return ( - 1);
}
while (* definition)
{
while (isspace(* definition))
++定义;
if (* definition == ' +')
{
* cb ++ = * definition ++;
while (isspace(* definition))
++ definition;
break ;
}
return ( - 1);
}
if (* definition)
return ( - 1);
* mb = 0 ;
* sb = 0 ;
* cb = 0 ;
如果(n + s > 254 )
return ( - 1);
if (map)
strcpy(map,mbuffer);
if (席位)
strcpy(seat,sbuffer);
if (command)
strcpy(command,cbuffer);
if (length)
* length = n + s;
if (count)
* count = s;
return ( 0 );
}
') { if(!row[0]) return(-1); for(i = 0 ; row[i] ; i++) { ++n; *mb++ = row[i]; if(n+s > 254) return(-1); } ++definition; while(isspace(*definition)) ++definition; continue; } if(*definition == 39) { p = strchr(definition+1,39); if(!p) return(-1); ++definition; while(definition != p) { *mb++ = *definition++; ++n; if(n+s > 254) return(-1); } ++definition; while(isspace(*definition)) ++definition; continue; } return(-1); } while(*definition) { while(isspace(*definition)) ++definition; if(*definition == '+') { *cb++ = *definition++; while(isspace(*definition)) ++definition; break; } return(-1); } if(*definition) return(-1); *mb = 0; *sb = 0; *cb = 0; if(n+s > 254) return(-1); if(map) strcpy(map,mbuffer); if(seats) strcpy(seats,sbuffer); if(command) strcpy(command,cbuffer); if(length) *length = n+s; if(count) *count = s; return(0); }
我强烈建议了解这段代码的主要思想,并将通用算法转换为.NET。逐行执行从C ++到VB.NET没有意义。
I strongly suggest getting the main idea of this code and translating the general algorithm to .NET. Doing it line-by-line doesn't make sense from C++ to VB.NET.
这篇关于将c ++代码转换为vb.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文