我想得到3个数字的输入,并作为输出多个结果.
我的代码:
t :: Integer -> Integer -> Integer -> (Integer,Integer,Integer)
t a b c = ((a+b)/2,(a+b+c)/3,(b+c)/2)
Run Code Online (Sandbox Code Playgroud)
但这似乎是一个问题:
Lab2.hs:17:17:
No instance for (Fractional Integer) arising from a use of `/'
Possible fix: add an instance declaration for (Fractional Integer)
In the expression: (a + b) / 2
In the expression: ((a + b) / 2, (a + b + c) / 3, (b + c) / 2)
In an equation for `t':
t a b c = ((a + b) …Run Code Online (Sandbox Code Playgroud) 当我尝试重置列表标记时,我得到一个空指针异常.
问题必定是因为我从未说过B和C是什么.(布尔B,整数C)我不知道该怎么做.
这是我的代码的一部分:
Marked[] marked;
//Create list marked!
public class Marked<B,C>{
public B bool;
public C comp;
}
public Graph(int N)
{
//Fill marked with false and 0
marked = new Marked[N];
for(int i=0;i<N;i++){
marked[i].bool = false;
marked[i].comp=0;
}
Run Code Online (Sandbox Code Playgroud)