Advertisement
Guest User

Fakultet

a guest
Oct 23rd, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include<stdio.h>
  2. #define MAX 100
  3.  
  4. int minBrojKazneni(int a[], int N) {
  5.     //Vasiot kod tuk
  6.    
  7.        
  8.         int i,j;
  9.         int t=0;
  10.         int suma=0;
  11.         for(i=0; i<N; i++)
  12. {
  13.   for(j=0; j<N-i-1; j++)
  14.   {
  15.     if( a[j] > a[j+1])
  16.     {
  17.       t = a[j];
  18.       a[j] = a[j+1];
  19.       a[j+1] = t;
  20.     }
  21.   }
  22. }
  23.         int b[N];
  24.         b[0]=a[0];
  25.         for(i=1;i<N;i++)
  26.         {
  27.             b[i]=b[i-1]+a[i];
  28.         }
  29.         for(i=0;i<N;i++)
  30.         {
  31.             suma+=b[i];
  32.         }
  33.         return suma;
  34.    
  35.  
  36. }
  37.  
  38. int main() {
  39.     int i, N;
  40.     int a[MAX];
  41.  
  42.     scanf("%d", &N);
  43.  
  44.     for (i=0;i<N;i++)
  45.         scanf("%d", &a[i]);
  46.  
  47.     int res = minBrojKazneni(a, N);
  48.     printf("%d\n", res);
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement