📄 2372.txt
字号:
///////////////////////////////////////////////////////
//D++ Again
//
//
#include <stdio.h>
#include <string.h>
char w[1000], *symbol="=+-*/0123456789\n";
bool check_comment(int &s)
{
do
{
while( w[s] && w[s] != '*' )
s++;
if( !w[s] || !w[ s+1 ] ) return false;
else if( w[ ++s ] == ')' ) return true;
}while(1);
return true;
}
bool check_expression(int &s)
{
do
{
while( w[s] && w[s] !='(' && w[s] != ')' )
{
if( !strrchr( symbol, w[s] ) ) return false;
s++ ;
}
if(w[s] == ')' ) return true;
if( !w[s] || !w[s+1] ) return false;
if( w[ ++s ] == '*' )
{
s++;
if( !check_comment( s ) ) return false;
}
else if( !check_expression( s ) ) return false;
s++;
}while(1);
}
bool check()
{
int s = 0;
while( w[s] )
{
if( w[s] == ')' ) return false;
if( w[s] == '(' )
{
if( w[s+1] && w[s+1] == '*' )
{
s+=2;
if( !check_comment( s ) ) return false;
}
else
{
s++;
if( !check_expression( s ) ) return false;
}
}
s++;
}
return true;
}
void init()
{
int i;
for( i=0; scanf("%1c",&w[i]) == 1 && w[i] != '#' ; i++ )
;
w[i] = '\0';
}
int main()
{
init();
if( check() ) printf( "YES\n" );
else printf( "NO\n" );
return 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -