AlexisRuiz

Untitled

Sep 26th, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. ///Funcion opcion 1___________________________________________________________________________________________________________
  5. void IngresarDatosEstudiantes(int t,int m[150][4]){
  6. int f,c;
  7.  
  8. printf("Ingrese los datos del estudiante en este orden seguido de la tecla ENTER: \n");
  9. printf("Sexo: Masculino-->0.\n      Femenino--->1.\n\nEstado Civil:Soltero--->0.\n             Casado--->1.\n             Viudo--->2.\n\nTrabaja Si--->0.\n        NO--->1.\n\nSUELDO(sin decimales).\n\n");
  10. for(f=1;f<=t;f++){///Filas
  11.     for(c=1;c<=4;c++){///Columnas
  12.  
  13.            if(m[f][c]==m[f][1]){
  14.             printf("Ingrese sexo del alumno #%d: \n",f);
  15.             scanf("%d",&m[f][c]);
  16.            }
  17.  
  18.            if(m[f][c]==m[f][2]){
  19.             printf("Ingrese estado civil del alumno #%d: \n",f);
  20.             scanf("%d",&m[f][c]);
  21.            }
  22.  
  23.            if(m[f][c]==m[f][3]){
  24.             printf("Ingrese si trabaja el alumno #%d: \n",f);
  25.             scanf("%d",&m[f][c]);
  26.             }///Fin si
  27.  
  28.  
  29.             if(m[f][c]==m[f][4] ){
  30.             printf("Ingrese el salario del alumno #%d (sindecimales): \n",f);
  31.             scanf("%d",&m[f][c]);
  32.            }
  33.  
  34.  
  35.  
  36.  
  37.  
  38.                     }///Fin columnas
  39.                 }///Fin filas
  40.             }///Fin Funcion
  41.  
  42.  
  43. ///Funcion que devuelve un float opcion 2______________________________________________________________________________________
  44.   float CalcularPor1(int t,int m[150][4]){
  45.   int f,cont=0;
  46.   float p,porce;
  47.   for(f=1;f<=t;f++){
  48.  
  49.         if(m[f][1]==0){
  50.             cont=cont+1;
  51.         }
  52.   }
  53.   p=cont/t;
  54.   porce=p*100;
  55.  
  56.  
  57.   return porce;
  58.   }
  59.  
  60. ///__________________________________________________________________________________________________________________________
  61.  
  62.  
  63. float CalcularPor2(int t,int m[150][4]){
  64.   int f,cont=0;
  65.   float p;
  66.  
  67.   for(f=1;f<=t;f++){
  68.  
  69.         if(m[f][1]==1){
  70.             cont=cont+1;
  71.         }
  72.  
  73.   }
  74.  
  75.   p=(cont/t)*100;
  76.  
  77.  
  78.   return p;
  79.   }
  80. ///__________________________________________________________________________________________________________________________
  81.  
  82.  void CantidadHMEC( int t,int e,int m[t][4]){///Calcular cantidad de hombres y mujeres para un estado civil ingresado
  83.  int f,contM=0,contF=0;
  84.  
  85.  for(f=1;f<=t;f++){
  86.     if(m[f][1]==0 && m[f][2]==e){
  87.         contM=contM+1;
  88.     }else if(m[f][1]==1 && m[f][2]==e){///Abre else
  89.      contF=contF+1;
  90.     }///Fin sino.
  91.  }///Fin for
  92.  
  93.  printf("La cantidad de hombres para el estado civil ingresado es de: %d \n",contM);
  94.  printf("La cantidad de mujeres para el estado civil ingresado es de: %d \n",contF);
  95.  
  96.  }///Fin funcion
  97.  
  98. ///__________________________________________________________________________________________________________________________
  99.  
  100. void SueldoMujeres(int salario,int t,int m[t][4]){///Calcula las mujeres que devengan un sueldo igual o mayor al ingresado.
  101. int f,contF=0;
  102. for(f=1;f<=t;f++){
  103.     if(m[f][1]==1 && m[f][4]>=salario){
  104.         contF=contF+1;
  105.        }///Fin si
  106.       }///Fin for
  107.  
  108.     if(contF==0){
  109.         printf("No hay mujeres que devengan un sueldo igual o mayor a %d\n",salario);
  110.     }else if(contF!=0){
  111.         printf("el numero de mujeres que trabajan y ganan un salario igual o mayor a %d es de %d\n",salario,contF);
  112.     }///Fin sino
  113.  
  114.  
  115.  
  116.     }///Fin Funcion
  117.  
  118. ///___________________________________________________________________________________________________________________________
  119.  
  120. void MostrarMatriz(int t,int m[t][4]){
  121. int f,c;
  122.  
  123. printf(" ");
  124. for(f=1;f<=t;f++){
  125.     for(c=1;c<=4;c++){
  126.         printf("matriz[%d][%d] %d ",f,c,m[f][c]);
  127.     }
  128.     printf("\n");
  129. }
  130. printf(" ");
  131.  
  132.  
  133. }
  134.  
  135.  
  136. ///***************************************************************************************************************************
  137. ///_____________________________________________________________________________________________________________________________
  138. int main()
  139. {
  140.  
  141.  
  142.      int matriz[150][4],opc=0,numE=0,eCivil=0,sueldoU=0;
  143.      float  p1;
  144.      //int p2=0;
  145.  
  146.  
  147.  
  148.      do{
  149.         printf("\t\t***MANEJO DE LOS DATOS PERSONALESDE LOS ESTUDIANTES DEL PROGRAMA \t\tDE TECNOLOGIA EN SISTEMAS DE LA  UCP.***\n");
  150.         printf("1.Ingrese el numero de estudiantes\n");
  151.         printf("2.Calcular el porcentaje de hombres y mujeres.\n");
  152.         printf("3.Calcular cantidad de hombres y mujeres para un estado civil.\n");
  153.         printf("4.Calcular y mostrar la distribución de mujeres solteras que trabajan\n");
  154.         printf("5.Salir.\n");
  155.         scanf("%d",&opc);
  156.  
  157.         switch(opc){
  158.  
  159.     case 1:
  160.         printf("Cuantos estudiantes va a ingresar?\n");
  161.         scanf("%d",&numE);
  162.  
  163.         IngresarDatosEstudiantes(numE,matriz);
  164.         printf("\n");
  165.  
  166.  
  167.         break;
  168.  
  169.     case 2:
  170.  
  171.           MostrarMatriz(numE,matriz);
  172.           printf("\n");
  173.           p1=CalcularPor1(numE,matriz);
  174.           printf("El procentage de hombres es de: %.2f",p1);
  175.           printf("\n");
  176.           int p2=CalcularPor2(numE,matriz);
  177.           printf("El procentage de mujeres es de: %d",p2);
  178.           printf("\n");
  179.  
  180.         break;
  181.  
  182.     case 3:
  183.         printf("Ingrese estado civil:\nRecuerde Soltero=0,Casado=1,Viudo=2.\n");
  184.         scanf("%d",&eCivil);
  185.  
  186.         CantidadHMEC(numE,eCivil,matriz);
  187.         printf("\n");
  188.         break;
  189.  
  190.     case 4:
  191.         printf("Ingrese sueldo:\n");
  192.         scanf("%d",&sueldoU);
  193.         SueldoMujeres(sueldoU,numE,matriz);
  194.         printf("\n");
  195.         MostrarMatriz(numE,matriz);
  196.         printf("\n");
  197.         break;
  198.  
  199.     case 5:
  200.        printf("HASTA LUEGO!!!!");
  201.        printf("\n");
  202.  
  203.         break;
  204.  
  205.  
  206.         }///Fin segun
  207.  
  208.      }while(opc!=5);
  209.  
  210.     return 0;
  211. }
Advertisement
Add Comment
Please, Sign In to add comment