| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1043 人关注过本帖
标题:C++画方框问题
只看楼主 加入收藏
suckdog
Rank: 1
等 级:新手上路
帖 子:130
专家分:0
注 册:2007-9-19
结帖率:41.67%
收藏
已结贴  问题点数:20 回复次数:3 
C++画方框问题
以下程序是画一个方框, 方框是空心的, 如图 :
XXXXXX
X    X
X    X
XXXXXX
我用的是2D array画的, a[i][j], 现在我要把方框中一个空白处填上字母S和F, 为什么我的程序总是司机, 没有syntax 错误, 但是每次填完我要输入的S点就死掉了, 大家帮我找一下错误在哪里
                           
#include <iostream>
using namespace std;

int main()
{
    int RSIZE, CSIZE, p;
    char start, start1, end, end1;
   
    cout<<"Enter the size of the maze:\n";
    cin>>RSIZE>>CSIZE;
   
    RSIZE=RSIZE+2;
    CSIZE=CSIZE+2;
    char a[RSIZE][CSIZE];
   
    //initialize the maze
       for (int i=0; i<RSIZE; i++)
    {   
            //Print offset
        for(int j=0; j<CSIZE; j++)
        {
                //print the width, which is the top and the bottom
            if (i==0 || i==RSIZE-1)
               a[i][j]='X';
                //print height
            else
            {
                    //the side
                if(j==0 || j==CSIZE-1)
                    a[i][j]='X';
                    //the center part of the box is empty
                else
                    a[i][j]=' ';
            }
        }
     }     
     
     cout<<"Make a starting point:\n";               《————————错误就在这里
     cin>>start>>start1;
     a[start][start1]='S';
     
     cout<<"Make an ending point:\n";
     cin>>end>>end1;
     a[end][end1]='F';
     
     //draw the maze
     for (int i=0; i<RSIZE; i++)
     {
         for (int j=0; j<CSIZE; j++)
         {
             if(j==CSIZE-1)
             {
                cout<<a[i][j]<<endl;
             }
             else
                cout<<a[i][j];
         }
     }
    system("pause");
    return 0;
}
                  
搜索更多相关主题的帖子: 方框 
2010-05-07 02:18
cnfarer
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:179
帖 子:3330
专家分:21157
注 册:2010-1-19
收藏
得分:20 
char start, start1, end, end1;
这个数据类型导致!改成int试试!

★★★★★为人民服务★★★★★
2010-05-07 07:20
xin310923
Rank: 5Rank: 5
等 级:职业侠客
威 望:1
帖 子:203
专家分:325
注 册:2009-12-22
收藏
得分:0 
同意二楼的观点
2010-05-11 22:01
南国利剑
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:29
帖 子:1165
专家分:3536
注 册:2010-4-12
收藏
得分:0 
严重支持二楼!

南国利剑
2010-05-12 10:48
快速回复:C++画方框问题
数据加载中...
 
   



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

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