Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/04/2015, 12:27
IVICP3
 
Fecha de Ingreso: febrero-2015
Mensajes: 61
Antigüedad: 9 años, 2 meses
Puntos: 0
No entiendo este código, MUY CORTO.

A ver si alguien me puede explicar como funciona la funcion "comprobar2", porque no la entiendo. Se supone que el proposito de la funcion es, si hay 2 elementos en el vector devuelve true, sino false, esta bien?


Código C:
Ver original
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define MAX 5
  4.  
  5.  
  6.  
  7. void rellenar(float vector[], int numpos){
  8.     int i;
  9.  
  10.     printf("\nDentro de la funcion 'rellenar'");
  11.    
  12.     for(i=0;i<numpos;i++) {
  13.         printf("\nIntroduce el numero real %d: ",i+1);
  14.         scanf("%f", &vector[i]);
  15.     }
  16.  
  17. }
  18.  
  19.  
  20. bool comprobar2(float vector[], int numpos){
  21.     int i;
  22.     bool encontrado= false;
  23.  
  24.    
  25.     for(i=0;i<2;i++){
  26.         if(i<2){       
  27.             encontrado =true;
  28.         }      
  29.     }
  30.     return encontrado;
  31.    
  32.  
  33. }
  34.  
  35.  
  36.  
  37.  
  38. void main(){
  39.     float vector[MAX];
  40.     int i;
  41.  
  42.     printf("EXAMEN UF2 PROGRAMACION");
  43.    
  44.     rellenar(vector, MAX);
  45.     if(comprobar2(vector,MAX)==true){
  46.         printf("\nSIIIIIIIII");
  47.     }else{
  48.         printf("\nNOOOOOOOO");     
  49.     }
  50.    
  51.  
  52.  
  53.  
  54.  
  55.     printf(" ");
  56.     system("pause");
  57.  
  58. }