在输入文件中设置无限值(∞)并在java中读取它 [英] Setting infinite value (∞) in the input file and reading it in java

查看:336
本文介绍了在输入文件中设置无限值(∞)并在java中读取它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

对于java程序,输入文件是一个矩阵。 Java程序会读取输入文件,然后做一些事情。

文件的每一行都包含行号,列号,两个节点之间边缘的权重。

如:

1,1,0

1,2,-1

1,3,2

...

自循环等于零,如果两个节点之间没有边,则它应该是无穷大(∞)。

如何在输入文件中设置无限?



我尝试过:



Hello,
For a java program, the input file is a matrix. Java program will do read the input file and then do some things.
Each line of the file contains row number, column number, the weight of the edge between two nodes.
such as:
1,1,0
1,2,-1
1,3,2
...
Self-loop is equal zero, and if there is no edge between two nodes, it should be infinite (∞).
How can I set infinite in the input file?

What I have tried:

Setting infinite value (∞) in the input file and reading it in java

推荐答案

没有这样的值可以插入数字:这是无限值的本质。

相反,我会写一些不是数字 - 如果你的文件是Unicode,那么像'i'或甚至'∞'这样的字符,特别是在我将数据转换回数字时读回文件时检查它。
There is no such value that you can insert as a number: that is the nature of "infinite values".
Instead, I'd write something that wasn't a number at all - a character like 'i' or even '∞' if your file is Unicode and specifically check for that when I read the file back while converting the values back to numbers.


这篇关于在输入文件中设置无限值(∞)并在java中读取它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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