| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
那位高手进来帮我看看!!#include "iostream.h"
#include "stdlib.h"
#define MAX 1000
int low,high;
int *a,*b,n;
void main()
{
a=(int *)malloc(sizeof(int));
b=(int *)malloc(sizeof(int));
int i=0;
cin>>n;
while(n!=0)
{
a=(int *)realloc(a,n*sizeof(int));
b=(int *)realloc(b,n*sizeof(int));
for(int j=0;j<n;j++)
{
cin>>a[j]>>low>>high;
b[j]=high-low;
}
int flag=1;
int max=a[0];
do
{
int now=0;
max=a[0];
for(j=0;j<n-1;j++)
{
if(a[j+1]>a[j])
{
max=a[j+1];
now=j+1;
}
}
flag=0;
for(j=0;j<n;j++)
{
if(a[j]<max)
{
a[j]+=b[j];
flag++;
}
}
}while((max<=10000)&&(flag!=0));
if((max<=10000)&&(n!=1))
cout<<"Case #"<<i+1<<":"<<endl<<"The actual year is "<<max<<"."<<endl<<endl;
else
cout<<"Case #"<<i+1<<":"<<endl<<"Unknown bugs detected."<<endl<<endl;
i++;
cin>>n;
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator