Scritto-04 09 17
Scritto-04 09 17
Cognome
Matricola
Risposta
3 i n t main () {
4 i n t x = -1 , y = 0 , z = 1;
5 printf ( " % d % d % d \ n " ,!x , !y , ! z );
6 return 0;
7 }
Risposta
Quesito 3. Indicare cosa stampa il seguente codice.
Risposta
3 i n t main () {
4 i n t i = 0;
5
6 while ( i <= 10)
7 printf ( " % d \ n " ,i ++);
8
9 do
10 printf ( " % d \ n " ,i );
11 while ( i ++ <= 10)
12
13 return 0;
14 }
Risposta
Risposta
Quesito 6. Indicare cosa stampa il seguente codice.
10 i n t main () {
11 printf ( " % d \ n " ,f (0));
12
13 return 0;
14 }
Risposta
1 s t r u c t x { i n t x ;} x = {0};
2 s t r u c t y { i n t x ;} y = x ;
Risposta
Risposta
Quesito 9. Indicare cosa stampa il seguente codice.
Risposta
Risposta
Esame di Programmazione M-Z (Parte 2)
4 Settembre 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 remove char() che
rimuove dalla struttura ogni occorrenza di un carattere specificato.
Precisazioni:
• Al termine della procedura la struttura deve contenere una sola riga, i.e. un solo
nodo di tipo struct text.