Advertisement
aunkang

Lab9-1

Jan 23rd, 2014
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2.  int main()
  3. {
  4.     int x,y[50],i,sum=0,count=0;
  5.     scanf("%d",&x);
  6.     for(i=0;i<=x-1;i++)
  7.     {
  8.         scanf("%d",&y[i]);
  9.         sum += y[i];
  10.     }
  11.     for(i=0;i<=x-2;i++)
  12.     {
  13.         int j,temp=0;
  14.         for(j=0;j<=x-2;j++)
  15.         {
  16.             if(y[j]<y[j+1])
  17.             {
  18.                 temp = y[j];
  19.                 y[j] = y[j+1];
  20.                 y[j+1] = temp;
  21.             }
  22.         }
  23.     }
  24.     i = 0;
  25.     while(sum/2>y[0])
  26.     {            
  27.         y[0] += y[i+1];
  28.         count += 1;
  29.         i += 1;
  30.     }
  31.    
  32.     if(count==1) printf("%s","Require 1 Party");
  33.     else printf("Require %d Parties",count);
  34.     system("PAUSE");
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement