如何将矩阵或数组写入文本文件? [英] How to write a matrix or array to a text file?

查看:117
本文介绍了如何将矩阵或数组写入文本文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我想使用visual basic将数组写入文本文件。对于5X5大小的阵列,输出应该是这样的。


0 0 0 0 0

0 0 0 0 0

0 0 0 0 0

0 0 0 1 0

0 0 0 0 0


所有元素均为零,除外一。当我尝试使用Print#1语句编写时,我在一行中获得一个元素。怎么做???


提前谢谢

Hello,

i want to write an array to a text file using visual basic. the output should look like this for a 5X5 sized array.

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 1 0
0 0 0 0 0

All the elements will be zero except one. When i am trying to write using Print#1 statement then i am getting one element on one line. How to do this???

thank you in advance

推荐答案

数据的实际情况是否真实重要该文件,或者你只需​​要能够将其读回数组?
Does it actually matter what the data looks like in the file, or do you just need to be able to read it back into the array?



实际上数据的外观是否真实重要喜欢在文件中,或者你只是需要能够将它读回到数组中?
Does it actually matter what the data looks like in the file, or do you just need to be able to read it back into the array?



你好,


数据应该像我输入的那样,因为它将被读作数组(矩阵) 5 X 5)后记。因此必须在两者之间留出空间。连续5个项目。

矩阵大小将根据要求而变化,因此无法使用类似的语句 - 打印#1 0 0 0 0 0.

感谢您的回复。


hello,

the data should look like as typed by me, as it will be read as array (a matrix of 5 X 5) afterwords. so its necessary to have spaces in between & 5 items in a row.
The matrix size will change according to the requirements, so its not possible to use a statement like- Print #1 0 0 0 0 0.

Thank you for your response.


我试图提出的一点是,您可以在一个语句中直接存储数组文件,并在以后再次检索它。 br />

否则,我会说你需要知道的是你可以用分号(; )结束Print语句以省略换行符。例如:

The point I was trying to make is that you can store an array straight to file in one statement, and retrieve it again later.

Otherwise, I''d say what you need to know is that you can end the Print statement with a semicolon (;) to leave out the line break. For example:

展开 | 选择 | Wrap | 行号


这篇关于如何将矩阵或数组写入文本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆