-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. 如何添加一个元素到我的数组的末尾?
- 5. 如何使用“where”参数在数组末尾添加图片?
- 6. 将单个数组列添加到2d数组的末尾。 Java
- 7. 添加到列表的末尾在LISP
- 8. sed的(1):在一个PHP数组的末尾添加一行
- 9. 如何在OpenCL中将元素添加到数组的末尾?
- 10. 如何在C++文件末尾添加数据?
- 11. 如何将字母添加到字符数组的末尾?
- 12. 在c文件末尾添加信息
- 13. 如何在uint8_t *的末尾添加int?
- 14. 如何在WebView的末尾添加TextView
- 15. 如何将新值添加到数值数组的末尾?
- 16. 在CSV文件末尾添加空列
- 17. 在列表末尾添加节点
- 18. 在c链接列表的末尾添加节点c
- 19. android在末尾添加'...'textview
- 20. 使用三重DES解密数据在原始文本末尾添加“\ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0”
- 21. C#在末尾增加一个元素的数组
- 22. Prolog - combine2如何防止在末尾添加空列表
- 23. 将列添加到文件的末尾
- 24. C#LINQ追加一个项目到一个数组的末尾
- 25. C-在数组末尾的神秘值
- 26. 如何将一个数字追加到数组的末尾?
- 27. C程序链表添加到末尾
- 28. 如何在C#中使用File.Append添加文件末尾的行#
- 29. 如何在文件末尾添加新行。使用只有C
- 30. 如何在参数末尾添加新行月食[编辑]
对于那些谁是关闭的范围太广。这里是他所使用的完整代码HTTP:/ /stackoverflow.com/a/40761005/2592042 –
谢谢你提到这一点。 – Johnny