Visual c++ C++希望根据用户的X和Y在框中添加字符。我该怎么做?
E根据从用户处获得的x和y放置在盒子内。。。在编码中,它被称为xstrt和ystrt。我只需要获得另一个查询,比如要放置在其中的元素数量,并获得不同x和y位置的输入,然后放置元素E。我不知道它将如何显示。。。这只是一盒巧克力。希望您能从编码本身理解。这是我第一次在这里发帖。如果有任何错误,请宽容 当前o/pVisual c++ C++希望根据用户的X和Y在框中添加字符。我该怎么做?,visual-c++,Visual C++,E根据从用户处获得的x和y放置在盒子内。。。在编码中,它被称为xstrt和ystrt。我只需要获得另一个查询,比如要放置在其中的元素数量,并获得不同x和y位置的输入,然后放置元素E。我不知道它将如何显示。。。这只是一盒巧克力。希望您能从编码本身理解。这是我第一次在这里发帖。如果有任何错误,请宽容 当前o/p ##### # # # # # # ##### 所需O/p ##### # # # E # # # ##### code: #include<iostream
#####
# #
# #
# #
#####
所需O/p
#####
# #
# E #
# #
#####
code:
#include<iostream>
using namespace std;
void main()
{
int wid, ht; // wid - width and ht - height
int xstrt, ystrt; // starting point position
cout << "Enter height = ";
cin >> ht;
cout << "Enter width = ";
cin >> wid;
cout << "Enter the start position x and y = ";
cin >> xstrt, ystrt;
cout << "\n\n";
for(int width=1; width<=wid; width++)
{
if(width <= 1)
for(int width=1; width<=wid; width++)
{
cout<< "#";
}
else if(width<ht)
{
cout<< endl;
for(int width2=1; width2<=wid; width2++)
{
if(width2==1 || width2==wid)
cout<< "#";
else
cout<< " ";
} //end of for variable width2
}// end of else if
else
{
cout<< endl;
for(int width3=1; width3<=wid; width3++)
{
cout<<"#";
}//end of for having variable width3
}// end of else
}// end of first for loop
}
有点困惑。高度和宽度重要吗?你只需要中间的1个字母“E”吗?如果用户输入均匀的高度和宽度会怎样?“E”在哪里-左上角、右上角、左下角、右下角?是的,只在方框内不同位置添加字母E。该位置位于同一行的任一侧。是否有用户检查?宽度4高度4 x 10 y 10要添加一个字母,表示x为起点,另一个字母表示y为终点,所有字母仅在框内。并放置一个符号/字符作为障碍,另一个字符作为检查点。并通过检查点找到从起点到终点的最短路径,每次一步移动距离。只有上、下、左、右。