Uva 11900 – Boiled Eggs

Problem:- http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=3051

Solution :-

#include<stdio.h>
int main()
{
int n,i,k,a,b,c,d[1000],t=1;
scanf(“%d”,&n);
while(t<=n)
{
int s=0;
scanf(“%d %d %d”,&a,&b,&c);
i=1;
while(i<=a)
{
scanf(“%d”,&d[i]);
i++;
}
k=0;
for(i=1;i<=a && i<=b;i++)
{
s+=d[i];
if(s>c)
break;
k++;
}
printf(“Case %d: %dn”,t,k);
t++;
}
return 0;
}
At First you can try to solve this problem if you can’t than see this code & find what’s your problem . If you copy paste this code you could not improve yourself in programming .

Posted by Shipu Ahamed

Leave a Reply