Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.46 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int pinakas[5][3] = {{1,2,3},{1,2,3},{1,2,3},{1,2,3},{1,2,3}};
  6.  
  7.     /*for(int i = 0; i < 5; i++)
  8.     {
  9.         printf("Polh %d \n", i + 1);
  10.    
  11.         for(int j = 0; j < 3; j++)
  12.         {
  13.             printf("Dwse thn mhnaia eispraxh tou %d mhna: \n", j + 1);
  14.             scanf("%d", &pinakas[i][j]);
  15.         }
  16.     }*/
  17.    
  18.     float moAithousas[5];
  19.    
  20.     for(int i = 0; i < 5; i++)
  21.     {      
  22.         float mo = 0;
  23.        
  24.         for(int j = 0; j < 3; j++)
  25.         {
  26.             mo += pinakas[i][j];
  27.         }
  28.        
  29.         moAithousas[i] = mo / 3;
  30.        
  31.         printf("Mo aithousas polis %d: %f\n", i + 1, moAithousas[i]);
  32.     }
  33.    
  34.     float moMina[3];
  35.  
  36.     for(int i = 0; i < 3; i++)
  37.     {      
  38.         float mo = 0;
  39.        
  40.         for(int j = 0; j < 5; j++)
  41.         {
  42.             mo += pinakas[j][i];
  43.         }
  44.      
  45.         moMina[i] = mo / 5;
  46.        
  47.         printf("Mo mina %d: %f\n", i + 1, moMina[i]);
  48.     }
  49.  
  50.  
  51.     float smallest = 9999;
  52.     int location;
  53.     int month;
  54.  
  55.     for(int i = 0; i < 5; i++)
  56.     {      
  57.         for(int j = 0; j < 3; j++)
  58.         {
  59.             if(pinakas[i][j] < smallest)
  60.             {
  61.                 smallest = pinakas[i][j];
  62.                 location = i + 1;
  63.                 month = j + 1;
  64.             }
  65.         }
  66.     }
  67.    
  68.     printf("Mikroteri ispraksi %f stin poli %d ton mina %d\n", smallest, location, month);
  69.    
  70.     return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement