Josif_tepe

Untitled

Aug 13th, 2025
497
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.     int n;
  5.     scanf("%d", &n);
  6.    
  7.     float vkupno = n;
  8.     float kolku_se_validni = 0.0;
  9.     for(int i = 0; i < n; i++) {
  10.         int broj;
  11.         scanf("%d", &broj);
  12.        
  13.         int zbir = 0;
  14.         for(int j = broj; j > 0; j /= 10) {
  15.             int cifra = j % 10;
  16.            
  17.             zbir += cifra;
  18.         }
  19.        
  20.         if(zbir < 10) {
  21.             kolku_se_validni += 1.0;
  22.         }
  23.     }
  24.    
  25.     float procent = kolku_se_validni / vkupno;
  26.     procent *= 100.0;
  27.    
  28.     printf("%.2f%%", procent);
  29.     return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment