Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

consume party by c

Posted by alisari at 2009-03-14 18:57:42 on Problem 3663
#include <iostream.h>
const int hi=2000 ;
/////////////////////
void main(){
 float a[hi],tem,s;
int  n,sum=0,i,j ;
cout<<"enter costume lenght(1 <S< 1,000,000) s = ";  cin>>s;
cout<<"\nenter number of cows(2<= N <= 20,000) N = ";cin>>n;
for( i=0;i<n;i++)
        {cout<<"\ta["<<(i+1)<<"]="; cin>>a[i];}
for( i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
 if(a[i]>a[j]){ tem=a[i];a[i]=a[j];a[j]=tem;}
for( i=0;i<n-1;i++)
for( j=i+1;j<n;j++)if(a[i]+a[j]>s)j=n; else sum++;
 cout<<"\n= "<<sum<<" nuber of pairs cows.";
cin>>n;        }
//////////////////////

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator