Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #define A 2
- #define B 3
- #define C 3
- void farmacisti_inferie(int *punt);
- int main ()
- {
- int matrice[A][B][C];
- int i;
- int j;
- int k;
- printf("Inserisci %d elementi tutti uguali a zero oppure 1 \n",A*B*C);
- for(i = 0; i < A;i++){
- for(j = 0; j < B; j++){
- for(k = 0; k < C; k++){
- do{
- scanf("%d",&matrice[i][j][k]);
- if(matrice[i][j][k] < 0 || matrice[i][j][k] >1)
- printf("Errore \n");
- }while(matrice[i][j][k] < 0 || matrice [i][j][k]>1);
- }
- }
- }
- //farmacia 7 del quartiere 4
- int cont = 0;
- for(i = 1, j = 2, k = 0; k < C;k++){
- if(matrice[i][j][k]==0){
- cont++;
- printf("Il farmacista %d della farmacia 7 del quartiere 4 non è in ferie \n",k);
- }
- }
- printf("In farmacia 7 del quartiere quattro ci sono %d farmacisti non in ferie \n",cont);
- //farmacisti in ferie
- farmacisti_inferie(&matrice[0][0][0]);
- return 0;
- }
- //funzione farmacisti in ferie
- void farmacisti_inferie(int *punt)
- {
- int contatore = 0;
- int i,j,k;
- for(i = 0; i < A; i++){
- contatore = 0;
- for(j = 0; j < B; j++){
- for(k = 0; k < C; k++){
- if(*(punt+i*B+j*C*k)!=0){
- contatore+=1;}
- }
- }
- }
- printf("Nel quartiere %d farmacisti in ferie sono %d \n",i,contatore);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement