Compiladores/Aula Prática 12: Difference between revisions

From Wiki**3

< Compiladores
(Redirected page to ist:Compiladores/Aula Prática 12)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{TOCright}}
#REDIRECT [[ist:Compiladores/Aula Prática 12]]
== Tópicos ==
Processamento semântico e geração de código Postfix (não optimizado).
 
== Exercício 1 ==
 
Traduza para Postfix (não optimizado) a seguinte função escrita em C:
<c>
int *click(int *x, int dim) {
  int *res, i;
  for (i = dim -2, res = x+dim -1; i >= 0; i-- )
    if (x [i ] > *res ) res = &x [i ];
  return res;
}
</c>
 
== Exercício 2 ==
Traduza para Postfix (não optimizado) a seguinte função escrita em C:
<c>
int main() {
  extern void printd ( double );
  double d, e;
  d = e = 3.3e-2;
  printd (d + e );
  return 0;
}
</c>
 
== Exercício 3 ==
Traduza para Postfix (não optimizado) a seguinte função escrita em C:
<c>
void isort(int a[], int length) {
  for (int i = 0; i < length; i++) {
    int v = a[i];
    for (int j = i - 1; j >= 0; j--) {
      if (a[j] <= v) break;
      a[j + 1] = a[j];
    }
    a[j + 1] = v;
  }
}
</c>
 
== Resoluções ==
* Ver: [[Code Generation]]. Procurar resolver sem consultar.
 
[[category:Compiladores]]
[[category:Ensino]]

Latest revision as of 19:18, 6 December 2018