Si consideri il seguente frammento programma:
Program E10(Input, Output); Var R : Array[1..N] Of Integer; Var i, j, c, k: Integer; Begin i:=1; j:=9; c:=0; While(i < j) Do Begin If(R[i]+R[j] > k) Then Begin c:=c+(j-i); i:=i+1; End Else j:=j-1 End; End.
Dire cosa contiene la variabile c al termine dell’esecuzione del frammento di programma, quando:
N = 9
R = [100,87,67,54,34,23,11,10,1];
k = 143;
R = [100,87,67,54,34,23,11,10,1];
k = 143;