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

高手帮忙看下 为什么程序老是过去了

Posted by SuperYanyan at 2010-02-17 15:35:21
#include<stdio.h>
void main()
{
	int n,num,z,m,i,h,peo,a[10000],t;
	scanf("%d",&n);
	for(z=0;z<n;z++)
	{
		scanf("%d%d",&num,&peo);
		for(m=0;m<peo;m++)
		{
			scanf("%d",&a[m]);
		}
		t=0;
		for(i=0;i<peo;i++)
		{
			for(h=0;h<peo;h++)
			{
				if(a[i]>a[h])
				{
					t=a[i];
					a[i]=a[h];
					a[h]=t;
				}
			}
		}
		t=0;
		for(m=0;m<peo;m++)
		{
			t=t+a[m];
			
			if(t>=num) 
			{
				 goto A;	A:printf("Scenario #%d\n%d\n",z+1,m+1);
				break;
			
			}
		
		} 
	
        if(t<num)
         printf("Scenario #%d\nimpossible\n",z+1);printf("\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