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 20081041019 at 2011-04-13 14:18:47 on Problem 1011
#include <iostream>
#include <cstring>
using namespace std;
int main(){
	int i,j,d,a[256][256],b[256],c[256],k=1,n=-1;
	bool f=true;
	//如果不等于0,且小于65进入循环
	while(k!=0&&k<=64){
		n++;
		//k木棒节数
		cin>>k;
		//如果为0,跳出循环
		if(k==0||k>64) break;
		//d为输入的第n组数据的最大值,
		//b[n]为输入的第n组数据的总和
		//c[n]保存最终结果
		d=0;
		b[n]=0;
		c[n]=0;
		//一次输入n组数据元素
		for(j=0;j<k;j++){
			cin>>a[n][j];
			b[n]=a[n][j]+b[n];
			//将最大值保存到d
			a[n][j]>=d ? d=a[n][j] : d=d;
			if(a[n][j]>50||a[n][j]<=0){
				f=false;
			}
		}
		//将最终结果保存到c[n]
		if(f==true){
			for(j=1;j<k;j++)
				if(b[n]%j == 0 && b[n]/j >=d){
					c[n] = b[n]/j;
				}
		}else{
			for(j=0;j<k;j++){
				b[n]=0;
				a[n][j]=0;
			}
			continue;
		}
		//去掉下面注释,则每输完一组数据,就输出对应结果
		//cout<<c[n]<<endl;
	}		
	//结果输出
	if(f==true){
	for(i=0;i<n;i++)
		cout<<c[i]<<endl;
	}
	return 0;
}

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