-4
A
回答
1
我相信,你正在使用此代码的矩阵前插入0。 How to add a column to the an array C#
此代码所需要的变化是
//c++; //remove this line
c = c + 2; //add two extra column for adding 0's, One for beginning one for end
int[,] matrix = new int[r, c];
其他的变化是
for (int row = 0; row < r; row++)
{
for (int col = 0; col < c - 1; col++) // reduce column loop by one
{
if (col == 0)
{
matrix[row, col] = 0;
}
else
{
Console.Write("Enter value for matrix[{0},{1}] = ", row, col - 1);
matrix[row, col] = (int)Convert.ToInt32(Console.ReadLine());
}
}
}
1
for (int row = 0; row < r; row++)
{
for (int col = 0; col < c-1; col++)
{
Console.Write("Enter value for matrix[{0},{1}] = ", row, col - 1);
matrix[row, col] = (int)Convert.ToInt32(Console.ReadLine());
}
matrix[row, col] = 0;
}
+0
谢谢你的帮助。 – Johnny
相关问题
- 1. 如何在Bootstrap中的一组行的末尾添加长列?
- 2. 如何将一个参数添加到数组的末尾?
- 3. 我如何在结构数组的末尾添加一个ADDITIONAL结构?在C
- 4. 如何在OpenCL中将元素添加到数组的末尾?
- 5. 如何将字母添加到字符数组的末尾?
- 6. 在c文件末尾添加信息
- 7. 如何在uint8_t *的末尾添加int?
- 8. 在列表末尾添加节点
- 9. 在c链接列表的末尾添加节点c
- 10. android在末尾添加'...'textview
- 11. C#在末尾增加一个元素的数组
- 12. 将列添加到文件的末尾
- 13. C#LINQ追加一个项目到一个数组的末尾
- 14. C-在数组末尾的神秘值
- 15. C程序链表添加到末尾
- 16. 如何在文件末尾添加新行。使用只有C
- 17. 如何在C#中使用File.Append添加文件末尾的行#
- 18. 何时在按钮的末尾添加“...”?
- 19. 将项目添加到队列末尾
- 20. PHP数组字符串键添加数字在末尾
- 21. 如何在列表末尾添加节点?
- 22. 如何使用python在列表的末尾添加字符串?
- 23. 如何在MQRabbit队列的末尾添加消息
- 24. 如何使用jQuery在html表格末尾添加列?
- 25. 如何在csv/txt文件的末尾添加新列python
- 26. 如何在另一个列表的末尾添加列表的内容?
- 27. PHP在手机浏览器中末尾添加0
- 28. 在字符串末尾添加一个double(C++)
- 29. 如何在DataGridview的末尾添加一行?
- 30. 如何在python文件末尾添加一堆“N”?
对于那些谁是关闭的范围太广。这里是他所使用的完整代码HTTP:/ /stackoverflow.com/a/40761005/2592042 –
谢谢你提到这一点。 – Johnny