aula 7 #include #include #include int i ; int v[29]; int f (void* a, void* b){ return *((int*)a) - *((int*)b); } srand(time(NULL)); for(i=0; i<30;i++){ v[i]= rand(); } qsort(v, 30, sizeof(int),f); Aula Prática 10 ex 42 a) a=6 b=6 b) a=5 b=6 ex 43 p(), f(), a local, b local, , todas as construcções do c ex 44 o programa todo excepto no f porque temos uma variável local b ex 45 a) main -> f1 -> f2 -> f3 [Solução: a-f3, b-f3, w-f3, z-f2, y-f1, x-global] b) main -> f1 -> f3 [Solução: a-f3, b-f3, w-f3, z-f1, y-f1, x-global] c) main -> f2 -> f3 -> f1 [Solução: a-f1, b-f3, w-f3, z-f1, y-f1, x-global] ex 46 DL - Dynamic Link (DL de quem chama) SL - Static Links (DL de quem está à volta) PC - Program Counter (?) 0 DL ? 1 SL ? 2 PC? 3 i 1 4 j 1 5 k 1 6 l 1 --start-- 7 DL 0 8 SL 0 9 PC? --main-- 10 DL 7 11 SL 0 12 PC? 13 i 2 14 j 2 15 SL 10 16 PC? --f-- 17 DL 10 18 SL 10 19 PC? 20 i 7 21 j 7 22 k 7 23 l 7 --g-- 24 DL 15 25 SL 10 26 PC? 27 i 3 ex 47 0 DL? 1 SL? 2 PC? 3 DL 0 4 SL 0 5 PC? 6 f? 7 3 --main-- 8 DL 3 9 SL 0 10 PC? 11 x 3 12 2 fact(3) 13 DL 8 14 SL 0 15 PC? 16 x 2 17 1 fact(2) 18 DL 13 19 SL 0 20 PC? 21 x 1 22 0 fact(1) 23 DL 18 24 SL 0 25 PC? 26 x 0 27 0