Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.46 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. void InicializarNotas(float Array[], unsigned short int dim)
  7. {
  8.     float calif;
  9.    
  10.     for(int i=0; i<dim; i++){
  11.     cout<<"Introduzca la nota numero\t"<<i<<"\t(negativa para finalizar):\t";
  12.     cin>>calif;
  13.     if (calif>=0) Array[i]=calif;
  14.     else {
  15.         for(i;i<dim;i++) Array[i]=-1;
  16.         break;    
  17.          }                 }
  18. }
  19.  
  20. void InsertarNota(float Array[], unsigned short int dim)
  21. {
  22.    
  23.     float insnota, n;
  24.     unsigned short int posicion, j;
  25.    
  26.     cout<<"Introduzca la posicion en que quiere insertar la nota:\t";
  27.     cin>>posicion;
  28.     cout<<"Ahora, introduzca la nota en cuestion:\t";
  29.     cin>>insnota;  
  30.        
  31.     for(j=dim; j>=posicion+1; j--) Array[j]=Array[j-1];                                      
  32.     Array[posicion]=insnota;
  33.  
  34. }
  35.  
  36. void Eliminar(float Array[], unsigned short int dim)
  37. {
  38.     unsigned short int posicion, j;
  39.    
  40.     cout<<"Introduzca la posicion cuya nota quiere eliminar:\t";
  41.     cin>>posicion;
  42.    
  43.     for(j=posicion; j<dim; j++) Array[j]=Array[j+1];
  44.     Array[dim-1]=-1;
  45.    
  46. }
  47.  
  48. void Consultar(float Array[])
  49. {
  50.  
  51.     unsigned short int posicion;
  52.    
  53.     cout<<"Introduzca la posicion cuya nota quiere consultar:\t";
  54.     cin>>posicion;
  55.     cout<<"La nota pedida es:\t"<<Array[posicion]<<endl;
  56. }
  57.  
  58. void Verificar(float Array[], unsigned short int dim)
  59. {
  60.                      
  61.        
  62.         for(int i=0; i<dim; i++){
  63.         cout<<"Nota numero\t"<<i<<":\t";
  64.         cout<<Array[i]<<endl;
  65.                                 }
  66. }
  67.    
  68.    
  69. int main(int argc, char *argv[])
  70. {
  71.     unsigned short int opcion, numero, dim=151;
  72.     float calif, Array[dim];
  73.    
  74.     InicializarNotas(Array, dim);
  75.    
  76.     do{
  77.    
  78.     cout<<endl<<endl<<"Ahora, elija opcion:"<<endl;
  79.     cout<<"1. Insertar nota"<<endl;
  80.     cout<<"2. Eliminar nota"<<endl;
  81.     cout<<"3. Consultar nota"<<endl;
  82.     cout<<"4. Finalizar"<<endl;
  83.  
  84.     cin>>opcion;
  85.     cout<<endl<<endl;
  86.    
  87.     if (opcion==1) InsertarNota(Array, dim);
  88.     else if (opcion==2) Eliminar(Array, dim);
  89.     else if (opcion==3) Consultar(Array);
  90.    
  91.        } while (opcion!=4);
  92.        
  93.    
  94.     cout<<endl<<"Si desea verificar las notas, introduzca 1. En caso contrario, introduzca otro valor: ";
  95.     cin>>numero;
  96.     cout<<endl;
  97.    
  98.     if(numero==1) Verificar(Array, dim);
  99.     cout<<endl;
  100.          
  101.    
  102.    
  103.     system("PAUSE");
  104.     return EXIT_SUCCESS;
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement