Month: September 2012

Write a program to construct a pyramid of numbers .

Solution :-



#include<stdio.h>
#include<string.h>
int main()
{
 int n,i,j,k;
 while(scanf(“%d”,&n)==1)
 {

     for(i=1;i<=n;i++){
         for(j=1;j<=n-i;j++)
         printf(” “);
         for(k=1;k<=i;k++)
         printf(“1”);
         printf(“n”);
     }
}
return 0;
}


/*  
Input :-
 5
 Output :-

        1
      1 1
    1 1 1
  1 1 1 1
1 1 1 1 1

*/









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 in Basic Programming, 0 comments

Uva 11597 – Spanning Subtree

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

Solution :-

#include<stdio.h>
int main()
{
    int a,i=1;
    while(scanf(“%d”,&a)==1 && a>1)
    {
        printf(“Case %d: %dn”,i,a/2);
        i++;
    }
    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 in Programming, Uva, 0 comments

LightOJ 1182 – Parity

Problem Link

Solution :-

 

Posted by Shipu Ahamed in Light Oj, Programming, 0 comments

LightOJ 1107 – How Cow

Problem:-http://www.lightoj.com/volume_showproblem.php?problem=1107

Solution :-

  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int t,k,x1,y1,x2,y2,x,y,n,i;
  5.     scanf(“%d”,&t);
  6.     for(k=1;k<=t;k++)
  7.     {
  8.         scanf(“%d%d%d%d%d”,&x1,&y1,&x2,&y2,&n);
  9.         printf(“Case %d:n,k);
  10.         for(i=0;i<n;i++)
  11.         {
  12.             scanf(“%d%d”,&x,&y);
  13.             if(x>x1 && x<x2 && y>y1 && y<y2)
  14.             printf(“Yesn);
  15.             else printf(“Non);
  16.         }
  17.     }
  18.     return 0;
  19. }
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 in Light Oj, 0 comments

LightOJ 1227 – Boiled Eggs

Problem:-http://www.lightoj.com/volume_showproblem.php?problem=1227

Solution :-

  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int n,i,k,a,b,c,d[1000],t=1;
  5.     scanf(“%d”,&n);
  6.     while(t<=n)
  7.     {
  8.         int s=0;
  9.         scanf(“%d %d %d”,&a,&b,&c);
  10.         i=1;
  11.         while(i<=a)
  12.         {
  13.             scanf(“%d”,&d[i]);
  14.             i++;
  15.         }
  16.         k=0;
  17.         for(i=1;i<=&& i<=b;i++)
  18.         {
  19.             s+=d[i];
  20.             if(s>c)
  21.             break;
  22.             k++;
  23.         }
  24.         printf(“Case %d: %dn,t,k);
  25.         t++;
  26.     }
  27.     return 0;
  28. }
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 in Light Oj, 0 comments

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 in Programming, Uva, 0 comments

Uva 11799 – Horror Dash

Problem Link

Solution :-

 

Posted by Shipu Ahamed in Programming, Uva, 0 comments

Uva 11462 – Age Sort

Problem Link

Solution :-

 

Posted by Shipu Ahamed in Programming, Uva, 0 comments

Uva 10812 – Beat the Spread!

Problem Link

Solution :-

 

Posted by Shipu Ahamed in Programming, Uva, 0 comments

Uva 10323 – Factorial! You Must be Kidding!!!

Problem:- http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=24&problem=1264&mosmsg=Submission+received+with+ID+10597223

Solution :-

#include<stdio.h>
int main()
{
long long n;
while(scanf(“%lld”,&n)==1)
{
if(n<0&&n%2==0)
printf(“Underflow!n”);
else if(n<0&&n%2!=0)
printf(“Overflow!n”);
else if(n==0||n<=7)
printf(“Underflow!n”);
else if(n==8)
printf(“40320n”);
else if(n==9)
printf(“362880n”);
else if(n==10)
printf(“3628800n”);
else if(n==11)
printf(“39916800n”);
else if(n==12)
printf(“479001600n”);
else if(n==13)
printf(“6227020800n”);
else if(n>13)
printf(“Overflow!n”);
}
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 in Programming, Uva, 0 comments