Scritto-01 02 17
Scritto-01 02 17
Cognome
Matricola
1 #d e f i n e BEGIN {
2 #d e f i n e END }
3
4 i n t main ()
5 BEGIN
6 i n t 7 hr33 = ’ \0 ’ +3;
7 i n t f0ur = ’A ’ /16;
8 i n t f1v3 = s i z e o f ( char )*5;
9 END
Risposta
Risposta
Risposta
Quesito 4. Indicare cosa stampa il seguente codice.
Risposta
Risposta
Risposta
Quesito 7. Indicare l’errore di sintassi nel seguente codice
1 enum E {A ,B , C } x = -1;
2 enum {D ,E , F } y = A ;
3 enum z = D;
Risposta
Risposta
3 s t a t i c i n t x = 1;
4
5 int *f( int y) {
6 s t a t i c i n t x = 2;
7 x += y ;
8 return & x ;
9 }
10
11 i n t main () {
12 i n t * p = f ( x );
13 printf ( " % d % d \ n " ,x ,* p );
14
15 return 0;
16 }
Risposta
Quesito 10. Indicare cosa stampa il seguente codice.
Risposta
Esame di Programmazione M-Z (Parte 2)
1 Febbraio 2017
Ingegneria e Scienze Informatiche
A.A. 2016-2017
d’immenso
viene memorizzato nel seguente modo:
T
M ' i l l u m i n o
NULL
NULL
NULL
NULL
d ' i m m e n s o
NULL
NULL
NULL
Le strutture che implementano tale struttura dati sono define nel seguente modo:
1 s t r u c t line {
2 char c ;
3 s t r u c t line * next ;
4 s t r u c t line * prev ;
5 };
6
7 s t r u c t text {
8 s t r u c t line * line ;
9 s t r u c t text * next ;
10 s t r u c t text * prev ;
11 };
Da notare che:
• La variabile T che punta all’intera struttura è di tipo struct text *.
• La lista concatenata di testo non contiene caratteri newline: le righe differenti di
testo sono gestite tramite la lista concatenata principale (struct text).
• Una riga vuota è rappresentata con un nodo di tipo struct text il cui campo line
punta a NULL.
Esercizio 1. Implementare il seguente prototipo della funzione copy text() che crea e
ritorna una copia della struttura dati.
Precisazioni: