如果有其他人遇到此类问题。我为你留下了我的帖子。
我在抽象和继承方面遇到了一些麻烦。
我的代码假设以矩形,三角形和平行四边形的形式输出星号。
问题是三角形和平行四边形是以框形式出现的。
如果有人可以帮我找到问题并解释原因。
平行四边形
enter image description here public String toString()
{
String output = "";
for (int i = 0; i < mHeight; i++)
{
for (int j = 0; j < mPbase+ i; j++)
{
output += "* ";
}
output += "\n";
for (int l = 0; l <= i; l++)
{
output += " ";
}
}
output += "The area of this Pall is " + calculatedArea() + " square
units.";
return output;
答案 0 :(得分:0)
这是因为在循环宽度和高度时,您不计算该图层的宽度。如果我的宽度为5,高度为5,那么做一个标准的双循环将给我一个5x5。而是尝试从内部for循环的宽度中减去高度索引。对于三角形,这将至少打印出一个颠倒的三角形
WITH cte as
(Select distinct [Base Product] product from tblCrossSellData),
cte_table_a as
(
SELECT DISTINCT OpOrID, OpPrSKU, OpQty, OpCancelled
FROM tblOrder op
JOIN tblpayment orp ON op.oporid = orp.PyOrID
WHERE orp.PyDateNew BETWEEN @startdate AND @enddate AND opprsku = @sku AND opcancelled = 0
),
cte_temp_b as
(
SELECT DISTINCT OpOrID, OpSoID, OpPrSKU, OpQty, ClID
FROM tblorder op
INNER JOIN tblProduct m ON m.prsku = p.opprsku
INNER JOIN tblproclass c ON c.prsku = p.opprsku
INNER JOIN tblpayment orp ON p.oporid = orp.PyOrID
INNER JOIN cte ON p.opprsku = cte.product
WHERE orp.PyDateNew BETWEEN @startdate AND @enddate AND opsoid = @store
AND OpCancelled = 0
),
cte_temp_c as
(
SELECT DISTINCT a.OpOrID, a.OpSoID
FROM cte_table_a a
INNER JOIN cte_table_b b ON a.OpOrID = b.OpOrID
)
Insert Into #Output
SELECT @vsku as 'Base SKU', @sku as 'Related SKU',
CAST(CAST(((CAST((SELECT COUNT(OpOrID) FROM cte_temp_c ) as float))
/CAST((SELECT COUNT(OpOrID) cte_temp_b ) as float)*100) as decimal(18,3)) as varchar(5)) + ' %'
AS 'Cross-Sell Rate'