Ver Mensaje Individual
  #3 (permalink)  
Antiguo 30/11/2013, 00:30
Avatar de vangodp
vangodp
 
Fecha de Ingreso: octubre-2013
Mensajes: 934
Antigüedad: 10 años, 7 meses
Puntos: 38
Respuesta: Problema con arreglo en funcion

Código C++:
Ver original
  1. #include <iostream>
  2. #include <windows.h>
  3. using namespace std;
  4.  
  5. void matriz( int opt = -1 ){
  6.      int x;
  7.      int y=1;
  8.      float m[3];
  9.      
  10.      for (x=0;x<3;x++){
  11.         y=m[x]=y+2;
  12.      }    
  13.      
  14.      // si opt recibe 0, 1 o 2 entra en if caso no reciba nada pasa a else  
  15.      if (opt==0 || opt==1 || opt==2 ){
  16.         cout<<m[opt]<<endl;            
  17.      }
  18.      else{     
  19.         for (x=0;x<3;x++){
  20.             cout<<m[x]<<endl;
  21.         }    
  22.      }
  23.  
  24. }    
  25.  
  26. int main (){
  27.    
  28.     //quita la doble barra y prueba el funcionamiendo de cada llamada
  29.    
  30.     //matriz(0);
  31.     //matriz(1);
  32.     //matriz(2);
  33.     //matriz();    
  34.    
  35.     //system("pause>null");
  36.     return 0;
  37. }