jmj.jitha
BAN USERnot the previous one that i posted. Its by mistake.. :p
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
int leap(int y)
{
if(y%400==0||y%4==0)
return 1;
else return 0;
}
int valid(int dd,int mm, int yyyy)
{
if(mm==2)
{
if(leap(yyyy))
{
if(dd<=29)
return 1;
else return 0;
}
else
{
if(dd<=28)
return 1;
else return 0;
}
}
else if(mm==4||mm==6||mm==9||mm==11)
{
if(dd<=30)
return 1;
else return 0;
}
else return 1;
}
int palin(int dd, int mm, int yyyy)
{
int y1,y2,i;
char str1[5],str2[5],str3[5];
int flag1=100,flag2=100;
y1=yyyy/100;
if(mm<10)
{
mm=10*mm;
if(mm==y1)
flag1=1;
}
else if(mm==10)
{
if(y1==1)
flag1=1;
}
else
{
itoa(mm,str1,10);
strrev(str1);
mm=atoi(str1);
if(mm==y1)
flag1=1;
}
y2=yyyy%100;
if(y2<10)
{
y2=y2*10;
if(dd==y2)
flag2=1;
}
else if(y2==10)
{
if(dd==1)
flag2=1;
}
else
{
itoa(y2,str1,10);
strrev(str1);
y2=atoi(str1);
if(dd==y2)
flag2=1;
}
if(flag1==1&&flag2==1)
return 1;
else
return 0;
}
void main()
{
int dd,mm,yyyy,st,en;
clrscr();
printf("\n Enter the starting year\t");
scanf("%d",&st);
printf("\n Enter the ending year.");
scanf("%d",&en);
for(yyyy=st;yyyy<=en;yyyy++)
{
for(mm=1;mm<=12;mm++)
{
for(dd=1;dd<=31;dd++)
{
if(valid(dd,mm,yyyy))
{
if(palin(dd,mm,yyyy))
{
printf("\n %d/%d/%d is a palindrome.",dd,mm,yyyy);
}
}
}
}
}
getch();
}
#include<stdio.h>
main()
{ int i,j,n,k, s=0,m;
int tmp=0;
printf("Enter the date in dd/mm/yyyy format \n");
scanf("%d/%d/%d",&j,&k,&n);
s=n+10000*k+ 1000000*j;
m=s;
while(s>0)
{ i=s%10;
s=s/10;
tmp=tmp*10 +i;
}
if(m==tmp)
printf("The date is pallindrome\n");
else
printf("The date is not pallindrome\n");
}
Why not put the 3 ltr bucket into the 5 ltr bucket, fill it fully that way only 2 ltrs are left in the 5 ltr bucket. pour half of the 5 liter bucket contents and pour 3 liters into the 5 liter bucket?
- jmj.jitha August 16, 2013