C# 乘法表显示错误
我必须编写一个代码来制作一个10x10乘法表,它的显示必须如下所示: 但是,我不知道如何正确显示代码。下面是我的代码。我知道我很接近,我只是不确定我做错了什么C# 乘法表显示错误,c#,multiplication,C#,Multiplication,我必须编写一个代码来制作一个10x10乘法表,它的显示必须如下所示: 但是,我不知道如何正确显示代码。下面是我的代码。我知道我很接近,我只是不确定我做错了什么 /* * This program displays a multiplication table of the product of every integer from 1 through 10 * multiplied by every integer from 1 through 10. * */ using Sy
/*
* This program displays a multiplication table of the product of every integer from 1 through 10
* multiplied by every integer from 1 through 10.
*
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DisplayMultiplicationTable
{
class Program
{
static void Main(string[] args)
{
int value = 10;
for (int x = 1; x <= value; ++x)
Console.Write("{0, 4}", x);
Console.WriteLine();
Console.WriteLine("_________________________________________");
for (int x = 1; x <= value; ++x)
Console.WriteLine("{0, 4}", x);
for (int row = 1; row <= value; ++row)
{
for (int column = 1; column <= value; ++column)
{
Console.Write("{0, 4}", row * column);
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}
/*
*这个程序显示从1到10的每个整数乘积的乘法表
*乘以从1到10的每个整数。
*
*/
使用制度;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
命名空间显示乘法表
{
班级计划
{
静态void Main(字符串[]参数)
{
int值=10;
对于(int x=1;x增加:
Console.Write("{0, 4}", row);
在语句的行开始之后
固定代码:
static void Main(string[] args)
{
int value = 10;
Console.Write(" ");
for (int x = 1; x <= value; ++x)
Console.Write("{0, 4}", x);
Console.WriteLine();
Console.WriteLine("_____________________________________________");
for (int row = 1; row <= value; ++row)
{
Console.Write("{0, 4}", row);
for (int column = 1; column <= value; ++column)
{
Console.Write("{0, 4}", row * column);
}
Console.WriteLine();
}
Console.ReadLine();
}
static void Main(字符串[]args)
{
int值=10;
控制台。写(“”);
对于(int x=1;xint值=10;
//缩进列标题
Write(“{0,4}”,null);
//写入列标题
对于(int x=1;x您能描述一下上面代码生成的显示有什么错误吗?他的显示不符合预期!第二个for循环在新行上打印出1-10,然后他在下面打印他的表。只需要重新排列行标题写入。与行上的值列表一样,我还需要1-10作为第一个从上到下运行列。就像乘法表一样。@AppDeveloper,您的原始答案缺少一整组数字,我看到您已经修复了它,所以我取消了下一票
int value = 10;
// Indent column headers
Console.Write("{0, 4}", null);
// Write column headers
for (int x = 1; x <= value; ++x)
Console.Write("{0, 4}", x);
// Write column header seperator
Console.WriteLine();
Console.WriteLine("_____________________________________________");
// Write the table
for (int row = 1; row <= value; ++row)
{
// Write the row header
Console.Write("{0, 4}", row);
for (int column = 1; column <= value; ++column)
{
// Write the row values
Console.Write("{0, 4}", row * column);
}
// Finish the line
Console.WriteLine();
}