1 - Implementar o codigo Java abaixo em linguagem C.
package br.com.anhanguera;
public class TestaMerge {
public static void main(String[] args) {
Nota[] notasServidorA = {
new Nota("mariana", 4),
new Nota("andre", 5),
new Nota("paulo", 8.5),
new Nota("carlos", 9)
};
Nota[] notasServidorB = {
new Nota("juliana", 3),
new Nota("jonas", 6.7),
new Nota("lucia", 7),
new Nota("ana", 9.3),
new Nota("guilherme", 10)};
Nota[] notasOrdenadas = intercala(notasServidorA, notasServidorB);
for( Nota nota : notasOrdenadas) {
System.out.println(nota.getAluno() + " " + nota.getValor());
}
}
private static Nota[] intercala(Nota[] notasServidorA, Nota[] notasServidorB) {
/* Obter o tamanho do vetor de resultado */
int total = notasServidorA.length + notasServidorB.length;
/* Inicializa as variaveis de elemento atual dos vetores */
int atualServidorA = 0;
int atualServidorB = 0;
int atualResultado = 0;
/* Declarar o vetor de resultados */
Nota[] resultado = new Nota[total];
while(atualServidorA < notasServidorA.length && atualServidorB < notasServidorB.length) {
Nota nota1 = notasServidorA[atualServidorA];
Nota nota2 = notasServidorB[atualServidorB];
if(nota1.getValor() < nota2.getValor()) {
resultado[atualResultado] = nota1;
atualServidorA++;
}
else {
resultado[atualResultado] = nota2;
atualServidorB++;
}
atualResultado++;
}
while(atualServidorA < notasServidorA.length) {
Nota notaA = notasServidorA[atualServidorA];
resultado[atualResultado] = notaA;
atualResultado++;
atualServidorA++;
}
while(atualServidorB < notasServidorB.length) {
Nota notaB = notasServidorB[atualServidorB];
resultado[atualResultado] = notaB;
atualResultado++;
atualServidorB++;
}
return resultado;
}
}