我想要做的是记住我在输入流中的位置,然后再回到那里.在使用mark()和reset()的java中非常简单,但我不知道如何在c#中实现这一点.没有这样的方法.
例如
public int peek()
{
try
{
file.x; //in java file.mark(1)
int tmp = file.read();
file.+ //in java file.reset();
return tmp;
}
catch (IOException ex) {}
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我有一个问题:如何在方法extendedEuclid中传递原始long类型作为引用?我发现它在java中是不可能的,还有其他解决方案吗?
参数long a必须通过引用传递,这是下面的代码.
public long extendedEuclid(long a, long b) //a have to be passed as a reference
{
long x = 0;
long y = 1;
long lx = 1;
long ly = 0;
long temp_a;
List quotient = new ArrayList<>();
while(b != 0)
{
quotient.add(a/b);
temp_a = a;
a = b;
b = temp_a % b;
}
long temp_x = x;
long temp_y = y;
for(int i=0; i<quotient.size()-1; i++)
{
x = lx - quotient.indexOf(i) * x;
y = …Run Code Online (Sandbox Code Playgroud)