
|
|

General Forum: Information Technology | *** Algorithms**** | |
| ee girl ki IT gurinchi baaga telusanukontaaa
Posted by: Mr. kumar Teja At: 17, Jul 2003 3:03:07 PM IST its not mod(n,7)
its (n/7)*2+a;
and here n should be an int so that truncation takes place.
where a=1 if its a saturday or a sunday.
so the program is
int n,weekends,a=0;
if(startdate==sataruday || startdate==sunday)
a=1;
weekends=(n/7)*2+a;
sreenivas check your logic where n=7 and its a saturday!! got it!!
Posted by: Miss The Girl At: 17, Jul 2003 3:01:47 PM IST thanq
Posted by: Mr. M.S.Reddy At: 11, Jun 2003 2:48:33 PM IST ur logic is good.
Posted by: Mr. benerjee At: 11, Jun 2003 2:46:42 PM IST Hi guys ok let me post my answer
If anybody knows better answet than this are more easy way to find out please post...
let n be the number of days between the given dates...
if (startdate=sat)
n=n+5;
a=0;
else if startdate=sunday)
n=n+6;
a=-1;
endif
number of weekends=mod(n,7) * 2 + a;
Posted by: Mr. M.S.Reddy At: 11, Jun 2003 2:39:26 PM IST yes...
you will be given starting date and ending date in dd-mm-yyyy and no of days between those 2 days....
Posted by: Mr. M.S.Reddy At: 11, Jun 2003 11:43:16 AM IST u mean three inputs
1)starting date
2)ending date
3)number od days
avuna??
Posted by: Mr. benerjee At: 11, Jun 2003 11:39:10 AM IST 1.Write an algorithm to Find Number Of Weekends[saturdays and sundays] between two dates..
Example: Find number of saturdays and sundays between june 1st 2000 to july 30th 2003
[The number of days is given.No need to calcuate the number of days...]
Alogithm should be simple and accurate....
Posted by: Mr. M.S.Reddy At: 11, Jun 2003 6:41:59 AM IST
|
|
|
 |
Advertisements |
|
 |
 |
Advertisements |
|