扫描地雷问题
源程序:# include < iostream >
using std::cout;
using std::cin;
using std::endl;
# include < cstdlib >
int main ()
{
int m;
int n;
cin >> m >> n;
if( m <= 0 || n <= 0 ) exit(0);
char ** a;
a = new char * [m];
for( int i = 0; i < m; i++ ) {
a[i] = new char [n];
}
for( int j = 0; j < m; j++ ) {
for( int t = 0; t < n ; t++ )
cin >> a[j][t];
cout << endl;
}
for( int x = 0; x < m; x++ )
for( int y = 0; y < n; y++ ){
if( a[x][y] == '*' ) {
for( int k = (x -1); k <=( x+1); k++ )
for ( int f = (y -1); f <= (y +1); f++ ){
if(f < 0 || f >= n || k < 0 || k >=m )
continue;
else
switch( a[k][f] ){
case '*':
break;
case '.':
a[k][f] = '1';
break;
case '1':
a[k][f] = '2';
break;
case '2':
a[k][f] = '3';
break;
case '3':
a[k][f] = '4';
break;
case '4':
a[k][f] = '5';
break;
case '5':
a[k][f] = '6';
break;
case '6':
a[k][f] = '7';
break;
case '7':
a[k][f] = '8';
break;
default :
break;
}
}
}
}
for( int d = 0; d < m; d++ ){
for( int s = 0 ; s < n; s++ ){
if(a[d][s]=='.') a[d][s]='0';
cout << a[d][s];
}
cout << endl;
}
for( int e = 0 ; e < m; e++){
delete a[e];
}
delete a;
return 0;
}
就是在提交到学校的acm 网站是编译不能通过
提示错误如下:
/3228/3228.cpp:1:23: iostream : No such file or directory
/3228/3228.cpp:2: `cout' not declared
/3228/3228.cpp:3: `cin' not declared
/3228/3228.cpp:4: `endl' not declared
/3228/3228.cpp:5:23: cstdlib : No such file or directory
/3228/3228.cpp: In function `int main()':
/3228/3228.cpp:11: `cin' undeclared (first use this
function)
/3228/3228.cpp:11: (Each undeclared identifier is
reported only once for each function it appears in.)
/3228/3228.cpp:12: `exit' undeclared (first use this
function)
/3228/3228.cpp:25: `cout' undeclared (first use this
function)
/3228/3228.cpp:25: `endl' undeclared (first use this
function)
希望有哪位高手能指点...........