循环跑案例
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define N 10005
int calcu(int *a,int *c,int n){
int i,sum=0;
for(i=0;i<n;i++)
if(*(a+i)>=*(c+i))
sum++;
return sum;
}
int main(){
// #ifndef ONLINE_JUDGE
// freopen("in.txt","r",stdin);
// #endif // ONLINE_JUDGE
int n,u=0;
int a[10],b[10],c[10];
while(scanf("%d",&n)&&n){
int i=0,j=1;
for(i=0;i<n;i++)
scanf("%d%d%d",&a[i],&b[i],&c[i]);
int out=-1;
int count=calcu(a,c,n);
for(j=1;count!=n&&j<=N;j++){
int re=0;
for(i=0;i<n;i++){
if(a[i]+b[i]==c[i]){
c[i]=1;
re=1;
}
else if(a[i]==c[i]&&(count<<1)>=n)
c[i]=1;
else
c[i]++;
}
if(re)
count=calcu(a,c,n);
}
end:
if(count==n){
out=j;
}
printf("Case %d: %d\n",++u,out);
}
return 0;
}