Fondamenti di Informatica 1 Esercizi di riepilogo.
-
Upload
nora-billingslea -
Category
Documents
-
view
236 -
download
6
Transcript of Fondamenti di Informatica 1 Esercizi di riepilogo.
Fondamenti di Informatica
1
Esercizi di riepilogo
Fondamenti di Informatica
2
MNP5
0010000000110110110110100010010110000
Fondamenti di Informatica
3
MNP5
0010000000110110110110100010010110000
00000000 000 000000001 000 100000010 001 000000011 001 100000100 010 0000000101 010 0100000110 010 1000000111 010 1100001000 011 00000001001 011 00100001010 011 01000001011 011 01100001100 011 100... ...
Fondamenti di Informatica
4
Puntatori
Fondamenti di Informatica
5
Fondamenti di Informatica
6
TXT2PHONE
Fondamenti di Informatica
7
TXT2PHONE
• Lettura file (fgets): per ogni riga– Estrazione dati
• struct con:– nome compagnia– numero in forma testuale
– Conversione stringa numero da forma testuale a cifre
– Scrittura riga nel file di uscita
Fondamenti di Informatica
8
TXT2PHONEchar txt2digit (char ch){ char phone_text_table ['z' - 'a' + 1] = { '2', '2', '2', /* abc */ '3', '3', '3', /* def */ '4', '4', '4', /* ghi */ '5', '5', '5', /* jkl */ '6', '6', '6', /* mno */ '7', '7', '7', '7', /* pqrs */ '8', '8', '8', /* tuv */ '9', '9', '9', '9' /* wxyz */ };
return phone_text_table[tolower(ch) - 'a'];}
Fondamenti di Informatica
9
TXT2PHONEvoid txt2phone (char s[], char t[]){ int i = 0, j = 0;
while (s[i] != '\0') { if (s[i] >= '0' && s[i] <= '9') t[j++] = s[i++]; else if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z')) t[j++] = txt2digit (s[i++]); else i++; } t[j] = '\0'; return;}
Fondamenti di Informatica
10
Noise gate
Fondamenti di Informatica
11