我想绘制一个明星的边缘,但我的计划只是在一个特定的位置上打造一条线和一颗星的网格? [英] I WANT TO DRAW A SLOPE OF STARS BUT MY PROGRAM ONLYPRINTS A GRID OF LINES AND ONE STAR AT A SPECIFIC LOCATION?

查看:37
本文介绍了我想绘制一个明星的边缘,但我的计划只是在一个特定的位置上打造一条线和一颗星的网格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

// Structure_Draw.Star.cpp:定义控制台应用程序的入口点。

//



#include" stdafx.h" b $ b #include< iostream>



#define第10行
#define Col 30

char grid [Row] [Col];



使用命名空间std;



struct point

{

int x;

< span style ="white-space:pre"> int y;

};



void setpoint(int,int ); $


int main()

{

int x;

int y;



cout<< "(X< 11)的坐标:";&b
cin>> x;

cout<< "(Y <31)的坐标:";&b
cin>> y;

for(int i = 0; i< Row; i ++)

{

for(int j = 0; j< Col ; j ++)

{

grid [i] [j] =' - ';

}

}

设定值(x,y);

for(int i = 0; i< Row; i ++)

{

for(int j = 0; j< Col; j ++)

{
$


cout<< grid [i] [j];

}

cout<< endl;

}



system(" pause");

返回0;

}

void setpoint(int x,int y)

{

point p;

px = x - 1;

py = y - 1;

grid [px] [py] ='* '; $
};

// Structure_Draw.Star.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

#define Row 10
#define Col 30
char grid[Row][Col];

using namespace std;

struct point
{
int x;
int y;
};

void setpoint(int, int);

int main()
{
int x;
int y;

cout << "Co-ordinates of (X<11) : ";
cin >> x;
cout << "Co-ordinates of (Y<31) : ";
cin >> y;
for (int i = 0; i < Row; i++)
{
for (int j = 0; j < Col; j++)
{
grid[i][j] = '-';
}
}
setpoint(x, y);
for (int i = 0; i < Row; i++)
{
for (int j = 0; j < Col; j++)
{

cout << grid[i][j];
}
cout << endl;
}

system("pause");
return 0;
}
void setpoint(int x, int y)
{
point p;
p.x = x - 1;
p.y = y - 1;
grid[p.x][p.y] = '*';
};

推荐答案

如果您告诉我们您输入了什么值,会有所帮助。 您最好将问题放在邮件的文本而不是标题中。

It would help if you told us what values you input.  It is also preferable that you put the question in the text of your message and not the title.

在设定值中,为什么还要打扰p?   没有任何问题。


     grid [x-1] [y-1];

In setpoint, why do you bother with p at all?  There is nothing wrong with 
     grid[x-1][y-1];

由于setpoint只在一个网格元素中存储一个星号,并且你只打印一次网格元素,为什么你期望你的输出包含多个星号? 

Since setpoint stores an asterisk in exactly one element of grid and you print each element of grid exactly once, why do you expect your output to contain more than one asterisk? 

您要寻找什么斜率:垂直(∞),水平(0),左上角到右下角(-1),右上角到左下角(1,或其他什么?

What slope are you looking for: vertical (∞), horizontal (0), top left to bottom right (-1), top right to bottom left (1, or something else?


这篇关于我想绘制一个明星的边缘,但我的计划只是在一个特定的位置上打造一条线和一颗星的网格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆