Advertisement
withoutsecurity

Farmacie.c

Feb 9th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #include<stdio.h>
  2. #define A 2
  3. #define B 3
  4. #define C 3
  5. void farmacisti_inferie(int *punt);
  6.  
  7. int main ()
  8. {
  9. int matrice[A][B][C];
  10. int i;
  11. int j;
  12. int k;
  13. printf("Inserisci %d elementi tutti uguali a zero oppure 1 \n",A*B*C);
  14. for(i = 0; i < A;i++){
  15. for(j = 0; j < B; j++){
  16. for(k = 0; k < C; k++){
  17. do{
  18. scanf("%d",&matrice[i][j][k]);
  19. if(matrice[i][j][k] < 0 || matrice[i][j][k] >1)
  20. printf("Errore \n");
  21. }while(matrice[i][j][k] < 0 || matrice [i][j][k]>1);
  22. }
  23. }
  24. }
  25. //farmacia 7 del quartiere 4
  26. int cont = 0;
  27. for(i = 1, j = 2, k = 0; k < C;k++){
  28. if(matrice[i][j][k]==0){
  29. cont++;
  30. printf("Il farmacista %d della farmacia 7 del quartiere 4 non è in ferie \n",k);
  31. }
  32. }
  33. printf("In farmacia 7 del quartiere quattro ci sono %d farmacisti non in ferie \n",cont);
  34. //farmacisti in ferie
  35. farmacisti_inferie(&matrice[0][0][0]);
  36. return 0;
  37. }
  38.  
  39. //funzione farmacisti in ferie
  40. void farmacisti_inferie(int *punt)
  41. {
  42.  
  43. int contatore = 0;
  44. int i,j,k;
  45. for(i = 0; i < A; i++){
  46. contatore = 0;
  47. for(j = 0; j < B; j++){
  48. for(k = 0; k < C; k++){
  49. if(*(punt+i*B+j*C*k)!=0){
  50. contatore+=1;}
  51. }
  52. }
  53. }
  54. printf("Nel quartiere %d farmacisti in ferie sono %d \n",i,contatore);
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement