2004/05 – Fase scolastica – 03

Si consideri il seguente frammento di programma: Function B(n: Integer): Integer; Forward; Function A(n: Integer): Integer; Begin    If (n = 0) Then       A:=0    Else If(n Mod 2 = 0) Then       A:=n+B(n)    Else       A:=B(n) End; Function B(n: Integer): Integer; Begin   If(n = 0) … Leggi tutto

2004/05 – Fase scolastica – 02

Si consideri il seguente frammento di programma Type  sequenza = array[1..100] of integer; Function verifica(vett: sequenza; n: Integer): Boolean; Var  i, j : integer;  appoggio: sequenza; Begin  j:=1;  For i:=1 To n Do      If(j = 0) Then         Begin            appoggio[j]:=vett[i];            … Leggi tutto

2004/05 – Fase scolastica – 01

Si consideri il seguente frammento di programma Type    sequenza = Array[1..100] Of Integer; Function calcola(vett: sequenza; n: Integer): Integer; Var  i, y, x: Integer; Begin  y:=0;  x:=vett[1];  For i:= 1 To n-1 Do    Begin       If(x < vett[i+1]) Then          Begin             y:=vett[i+1]-x+y; ... Leggi tutto

2011/12 – Fase scolastica – 12

È dato il seguente programma: Program E12(Input, Output); Var   T: Array[0..7] Of Integer; Procedure f(i, dim: Integer); Begin   If(i < dim) Then   Begin         f(2*i+1, dim);         Write(T[i]);         f(2*i+2, dim)     End; End; Begin   T[0]:=1;   T[1]:=2;   T[2]:=3;   ... Leggi tutto

2011/12 – Fase scolastica – 10

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             … Leggi tutto

2011/12 – Fase scolastica – 08

È dato il seguente programma: Program E8(Input, Output); Const   nrig=5;   ncol=5; Var   i, j: Integer;   m : Array[0..nrig-1, 0..ncol-1] Of Integer; Begin   For i:=0 to nrig-1 do      For j:=0 to ncol-1 do         m[i, j]:=i*j+j;   For j:=ncol-1 downto 0 do     Begin   … Leggi tutto

2011/12 – Fase scolastica – 07

È dato il seguente programma: Program E7(Input, Output); Var   x, y: Integer; Procedure alfa(Var x: Integer; y: Integer); Begin   y:=x*y;   x:=x*y End; Procedure beta(Var x: Integer; y: Integer); Begin   x:=x*y;   y:=x*y End; Begin   x:=3;   y:=3;      alfa(x, y);   write(‘x=’, x);    write(‘ y=’, y);   x:=3;  … Leggi tutto

2011/12 – Fase scolastica – 06

È dato il seguente programma: Program E6(Input, Output); Var   i, c: Integer; Begin   c:=0;   i:=0;   While i < 100 Do   Begin       c:=c+1;       If(c Mod 2 0) Then         i:=i+1   End;   Writeln('c=', c); End. Cosa viene visualizzato a video dall’esecuzione ... Leggi tutto