Advertisement
Josif_tepe

Untitled

Nov 12th, 2022
924
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5.     int N;
  6.     scanf("%d", &N);
  7.     float vneseni = N;
  8.     float prosti = 0;
  9.     for(int i = 0; i < N; i++) {
  10.         int x;
  11.         scanf("%d", &x);
  12.        
  13.         int prost = 1;
  14.        
  15.         for(int j = 2; j < x; j++) {
  16.             if(x % j == 0) {
  17.                 prost = 0;
  18.             }
  19.         }
  20.         if(prost == 1) {
  21.             printf("%d ", x);
  22.             prosti++;
  23.         }
  24.     }
  25.     printf("%f ", (prosti / vneseni) * 100);
  26.  
  27.     return 0;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement