frostblooded

New Task 4

Nov 18th, 2016
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.77 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.     double nums[64];
  5.  
  6.     int nums_size = 0;
  7.     while(scanf("%lf", &nums[nums_size]) != EOF) {
  8.         nums_size++;
  9.     }
  10.    
  11.     double not_repeated_nums[64];
  12.     int i;
  13.     int j;
  14.     int not_repeated_size = 0;
  15.     for(i = 0; i < nums_size; i++) {
  16.         for(j = 0; j < not_repeated_size; j++) {
  17.             if(nums[i] == not_repeated_nums[j]) {
  18.                 break;
  19.             }
  20.         }
  21.  
  22.         if(j == not_repeated_size) {
  23.             not_repeated_nums[not_repeated_size] = nums[i];
  24.             not_repeated_size++;
  25.         }
  26.     }
  27.  
  28.     double sum = 0;
  29.  
  30.     for(i = 0; i < not_repeated_size; i++) {
  31.         // Fake %
  32.         double num = not_repeated_nums[i];
  33.  
  34.         while(num >= not_repeated_size) {
  35.             num -= not_repeated_size;
  36.         }
  37.  
  38.         sum += num;
  39.     }
  40.  
  41.     printf("%d\n", not_repeated_size);
  42.     printf("%.3lf\n", sum);
  43.    
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment