Hi,
Here is a much simpler version of my time scheduling program. As you can see
in the GV (Global Variable class) I have 2 arrays gaSumWorkDays (already
initialized with the values) and gaSeconds. All I want to do when I run my
CVerifyMissingTime class is to verify whether the sum of the 2 colums of
gaSeconds in gaSumWorkDays is > 0.
I hope that this is more intuitive than the first version.
Here is the code below. I have indeted it to make it clearer.
TIA
Roy
using System;
class cMain
{
public static int Main()
{
int lnTotMissingTime=0;
int t = DateTime.Now.Minute*60+DateTime.Now.Second;
Console.WriteLine("TimeStarted "+t);
lnTotMissingTime=CVerifyMissingTime.VerifyMissingT ime();
Console.WriteLine("Total No of Missing Time {0}
",lnTotMissingTime);
t = DateTime.Now.Minute*60+DateTime.Now.Second;
Console.WriteLine("Time Ended "+t);
Console.ReadLine();
return 0;
}
}
public class GV
{
public const int kNoWeeks=11;
public static int gnSumSeconds = 0;
public static int[] gaWorkDays= new int [7];
public static int[] gaSumWorkDays = new int[61]
{ 0
,1,0,1,0,1,0,1,1,1,1,1,0,1,1,1,0,1,1,0,1,1,0,1,1,1 ,0,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0,1,1,1,0,1,1,1,1 ,1,0,1,1,1,0,1,1,1,0};
public static int[,] gaSeconds = new int [kNoWeeks+1,3]
{
{ 0, 0, 0},
{ 0, 9, 0},
{ 0, 17, 1},
{ 0, 24, 2},
{ 0, 30, 3},
{ 0, 35, 4},
{ 0, 39, 5},
{ 0, 42, 6},
{ 0, 44, 7},
{ 0, 45, 8},
{0, 0, 9},
{0, 0, 10}};
}
class CVerifyMissingTime
{
public static int VerifyMissingTime() {
int lnSumMissingTime=0;
for (int xxxLoop=1 ; xxxLoop<=10; xxxLoop++) {
lnSumMissingTime=0;
for (int lp1=1 ; lp1<=GV.kNoWeeks-5 ; lp1++) {
for (int lp2=lp1+1 ; lp2<=GV.kNoWeeks-4 ;
lp2++) {
for (int lp3=lp2+1 ;
lp3<=GV.kNoWeeks-3 ; lp3++) {
for (int lp4=lp3+1 ;
lp4<=GV.kNoWeeks-2 ; lp4++) {
for (int lp5=lp4+1 ;
lp5<=GV.kNoWeeks-1 ; lp5++) {
for (int
lp6=lp5+1 ; lp6<=GV.kNoWeeks ; lp6++) {
if
(GV.gaSumWorkDays[GV.gaSeconds[lp1,1]+GV.gaSeconds[lp2,2]]>0) {
lp6=lp5=lp4=100;
continue;
}
if
(GV.gaSumWorkDays[GV.gaSeconds[lp1,1]+GV.gaSeconds[lp2,2]]>0) {
lp6=lp5=100;
continue;
}
if
(GV.gaSumWorkDays[GV.gaSeconds[lp1,1]+GV.gaSeconds[lp3,2]]>0) {
lp6=lp5=100;
continue;
}
if
(GV.gaSumWorkDays[GV.gaSeconds[lp2,1]+GV.gaSeconds[lp3,2]]>0) {
lp6=lp5=100;
continue;
}
if
(GV.gaSumWorkDays[GV.gaSeconds[lp1,1]+GV.gaSeconds[lp2,2]]>0) {
lp6=100;
continue;
}
if
(GV.gaSumWorkDays[GV.gaSeconds[lp1,1]+GV.gaSeconds[lp3,2]]>0) {
lp6=100;
continue;
}
if
(GV.gaSumWorkDays[GV.gaSeconds[lp1,1]+GV.gaSeconds[lp4,2]]>0) {
lp6=100;
continue;
}
if
(GV.gaSumWorkDays[GV.gaSeconds[lp2,1]+GV.gaSeconds[lp3,2]]>0) {
lp6=100;
continue;
}
if
(GV.gaSumWorkDays[GV.gaSeconds[lp2,1]+GV.gaSeconds[lp4,2]]>0) {
lp6=100;
continue;
}
if
(GV.gaSumWorkDays[GV.gaSeconds[lp3,1]+GV.gaSeconds[lp4,2]]>0) {
lp6=100;
continue;
}
if
(GV.gaSumWorkDays[GV.gaSeconds[lp1,1]+GV.gaSeconds[lp2,2]]>0) {
continue;
}
if
(GV.gaSumWorkDays[GV.gaSeconds[lp1,1]+GV.gaSeconds[lp3,2]]>0) {
continue;
}
if
(GV.gaSumWorkDays[GV.gaSeconds[lp1,1]+GV.gaSeconds[lp4,2]]>0) {
continue;
}
if
(GV.gaSumWorkDays[GV.gaSeconds[lp1,1]+GV.gaSeconds[lp5,2]]>0) {
continue;
}
if
(GV.gaSumWorkDays[GV.gaSeconds[lp2,1]+GV.gaSeconds[lp3,2]]>0) {
continue;
}
if
(GV.gaSumWorkDays[GV.gaSeconds[lp2,1]+GV.gaSeconds[lp4,2]]>0) {
continue;
}
if
(GV.gaSumWorkDays[GV.gaSeconds[lp2,1]+GV.gaSeconds[lp5,2]]>0) {
continue;
}
if
(GV.gaSumWorkDays[GV.gaSeconds[lp3,1]+GV.gaSeconds[lp4,2]]>0) {
continue;
}
if
(GV.gaSumWorkDays[GV.gaSeconds[lp3,1]+GV.gaSeconds[lp5,2]]>0) {
continue;
}
if
(GV.gaSumWorkDays[GV.gaSeconds[lp4,1]+GV.gaSeconds[lp5,2]]>0) {
continue;
}
lnSumMissingTime++;
}
}
}
}
}
}
}
Console.WriteLine("Missing Time {0}",lnSumMissingTime);
return lnSumMissingTime;
}
}