Pauta Examen Lenguaje de Programación 2005-1
Jorge López R.


1. (1 punto)
struct a{ 
int x;
struct a *anterior;
struct a *siguiente;
};

respuesta:
struct a *aux;
aux = (struct a *)malloc(sizeof(struct a));
aux->x = p->x;
aux->siguiente = p->siguiente;
aux->anterior = p;
p->siguiente = aux;
aux->siguiente->anterior = aux;

2. (1 punto)

struct nodo{
int x;
struct nodo *siguiente;
};
respuesta:
void concatena(
struct nodo *p, struct nodo *q){
struct nodo *aux;
aux = p;
if(aux != NULL){
while (aux->siguiente != NULL)aux=aux->siguiente;
aux->siguiente = q;
} else {
p = q;
}
}

3. (2 puntos) 
Respuesta:
int numCeros(int m[][], int f, int c){
int nceros = 0, i ,j;
for(i = 0; i < c; i++)
for
(j = 0; j < f; j++)if(m[i][j] == 0) nceros++;
retun nceros;
}
4. (2 puntos)
struct alumno {
float notaFinal;
char nombre[64];
};
Respuesta:
void alumnos(char * archivo){
FILE *f;
struct alumno x;
int nalumnos = 0, nrep = 0 nap = 0.0;
float nacumulada = 0.0;
f = fopen(archivo, "r+b");
while(fread(&x, 1, sizeof(struct alumno), f)>0){
nalumnos++;
naculmulada =
naculmulada + a.notaFinal;
if(a.notaFinal >= 4) nap++;
else nrep++;
}
printf("promedio: %f, numero de aprobados: %d, numero reprobados: %d\n", nacumulada/nalumnos, nap, nrep);
}