| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 880 人关注过本帖
标题:扫描地雷问题
只看楼主 加入收藏
lcm
Rank: 4
等 级:贵宾
威 望:13
帖 子:140
专家分:0
注 册:2005-2-4
收藏
 问题点数:0 回复次数:2 
扫描地雷问题
源程序:

# 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)


希望有哪位高手能指点...........
搜索更多相关主题的帖子: 地雷 int std using 扫描 
2005-03-31 19:08
lcm
Rank: 4
等 级:贵宾
威 望:13
帖 子:140
专家分:0
注 册:2005-2-4
收藏
得分:0 
原来是学校提交的编译软件的问题
只要头文件改为 #include<iostream>
                           #include<cstdlib>
呵呵这样就行了

从 小 事 做 起,脚 踏 实 地 ~
2005-04-05 08:04
lcm
Rank: 4
等 级:贵宾
威 望:13
帖 子:140
专家分:0
注 册:2005-2-4
收藏
得分:0 
就是头文件中不要有空格出现

从 小 事 做 起,脚 踏 实 地 ~
2005-04-05 08:06
快速回复:扫描地雷问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.037823 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved