我认为这可能是一个非常简单的问题,但我还没有弄清楚.如果我有一个像这样的二维数组:
int[,] matris = new int[5, 8] {
{ 1, 2, 3, 4, 5,6,7,8 },
{9,10,11,12,13,14,15,16},
{ 17,18,19,20,21,22,23,24 },
{ 25,26,27,28,29,30,31,32 },
{ 33,34,35,36,37,38,39,40 },
};
Run Code Online (Sandbox Code Playgroud)
和一个for循环,像这样:
for (int r = 0; r < 5; r++)
{
for (int j = 0; j < 8; j++)
Console.Write("{0} ", matris[r, j]);
Console.WriteLine();
}
Run Code Online (Sandbox Code Playgroud)
所以使用这段代码我打印出多维数组.但是如何打印阵列的转置?
对于复出的前100篇论文,我的程序每张印刷版需要2美元.如果用户打印出超过一个hundread副本,对于每个副本都是hundread,每个副本需要1个数据(所以如果我想打印出101个副本,那么价格应该是200 + 1,101:1副本1美元前100份每份2美元).这是我的代码:
int CopyCost = 2;
int ammountOfCopies;
int discount = 1;
Console.WriteLine("How many copies would you like?: ");
ammountOfCopies = int.Parse(Console.ReadLine());
for (int i = 0; i < ammountOfCopies; i++)
{
if (ammountOfCopies > 100)
CopyCost = 2 - discount;
else
CopyCost = 2;
CopyCost *= ammountOfCopies;
}
Console.WriteLine("The total cost for your copies is: {0} ", CopyCost);
Console.ReadLine();
Run Code Online (Sandbox Code Playgroud)
但我遇到的问题是,如果我选择写出101份副本,它会将每份副本折扣为1美元,而不仅仅是100以上的副本.