Optimization Topics/Exercise 02: Difference between revisions
From Wiki**3
Created page with "Considere a seguinte função em C: # Que optimizações independentes da máquina são possíveis? # Traduza-a para Postfix optimizado. <c> int *fun(int *a, int *b, int len) { ..." |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 3: | Line 3: | ||
# Traduza-a para Postfix optimizado. | # Traduza-a para Postfix optimizado. | ||
<c> | <source lang="c"> | ||
int *fun(int *a, int *b, int len) { | int *fun(int *a, int *b, int len) { | ||
int *c = (int *)malloc(2 * 4), i; | int *c = (int *)malloc(2 * 4), i; | ||
| Line 10: | Line 10: | ||
return c; | return c; | ||
} | } | ||
</ | </source> | ||
Latest revision as of 18:06, 14 May 2019
Considere a seguinte função em C:
- Que optimizações independentes da máquina são possíveis?
- Traduza-a para Postfix optimizado.
int *fun(int *a, int *b, int len) {
int *c = (int *)malloc(2 * 4), i;
for (i = 0; i < (len < 2 ? len : 2); i++)
c[i] = a[i] + b[i];
return c;
}