wats wrong with the program

#include<iostream>
#include<string>
#include<fstream>

using namespace std;
const int NUM_ROW=8;
const int NUM_COL=7;
void addArray(int sum1, int sum2, int sum3, int sum4m,int sum5,int sum6, int sum7, int sum8,int schedule[][NUM_COL],string employee[8],string days[8][0]);
void mostHrs(int schedule[][NUM_COL],string employee[8],string days[8][0]);
int FindEight(int schedule[][NUM_COL]);





int main()
{
int sum1, sum2, sum3, sum4m,sum5,sum6, sum7, sum8;
string days[8][0]={"su","m","t","w","h","f","sa","totals"};
int schedule[NUM_ROW][NUM_COL]={{2,4,3,4,5,8,8},
{7,3,4,3,3,4,4},
{3,3,4,3,3,2,2},
{9,3,4,7,3,4,1},
{3,5,4,3,6,3,8},
{3,4,4,6,3,4,4},
{3,7,4,8,3,8,4},
{6,3,5,9,2,7,9}};

string employee[8]= {"employee 0", "employee 1","employee 2", "employee 3","employee 4","employee 5" ,"employee 6","employee 7"};


addArray(sum1, sum2, sum3, sum4m,sum5,sum6, sum7, sum8,schedule,employee,days);
mostHrs(schedule,employee,days);
FindEight(schedule);

return 0;

}

void addArray(int sum1, int sum2, int sum3, int sum4,int sum5,int sum6, int sum7, int sum8,int schedule[][NUM_COL],string employee[8],string days[8][0])
{


for(int r1=0;r1<1;r1++)
{
for(int c1=0;c1<NUM_COL;c1++)
{
sum1=sum1+schedule[r1][c1];
}
}
for(int r2=1;r2<2;r2++)
{
for(int c2=0;c2<NUM_COL;c2++)
{
sum2=sum2+schedule[r2][c2];
}
}
for(int r3=2;r3<3;r3++)
{
for(int c3=0;c3<NUM_COL;c3++)
{
sum3=sum3+schedule[r3][c3];
}
}
for(int r4=3;r4<4;r4++)
{
for(int c4=0;c4<NUM_COL;c4++)
{
sum4=sum4+schedule[r4][c4];
}
}
for(int r5=4;r5<5;r5++)
{
for(int c5=0;c5<NUM_COL;c5++)
{
sum5=sum5+schedule[r5][c5];
}
}
for(int r6=5;r6<6;r6++)
{
for(int c6=0;c6<NUM_COL;c6++)
{
sum6=sum6+schedule[r6][c6];
}
}
for(int r7=6;r7<7;r7++)
{
for(int c7=0;c7<NUM_COL;c7++)
{
sum7=sum7+schedule[r7][c7];
}
}
for(int r8=7;r8<8;r8++)
{
for(int c8=0;c8<NUM_COL;c8++)
{
sum8=sum8+schedule[r8][c8];
}
}
cout<<" "<<days[8][0]<<endl;
cout<<employee[8]<<schedule[NUM_ROW][NUM_COL]<<endl;
}

void mostHrs(int schedule[][NUM_COL],string employee[8],string days[8][0])

{
int sum1, sum2,sum3, sum4, sum5,sum6,sum7,sum8;
int most=0;
int emost=0;
for(int r1=0;r1<1;r1++)
{
for(int c1=0;c1<NUM_COL;c1++)
{
sum1=sum1+schedule[r1][c1];
most=sum1;
}
}
for(int r2=1;r2<2;r2++)
{
for(int c2=0;c2<NUM_COL;c2++)
{
sum2=sum2+schedule[r2][c2];
if(sum2>sum1)
{
most=sum2;
emost=1;
}
else
most=most;
}
}
for(int r3=2;r3<3;r3++)
{
for(int c3=0;c3<NUM_COL;c3++)
{
sum3=sum3+schedule[r3][c3];
if(sum3>most)
{
most=sum3;
emost=2;
}
else
most=most;
}
}
for(int r4=3;r4<4;r4++)
{
for(int c4=0;c4<NUM_COL;c4++)
{
sum4=sum4+schedule[r4][c4];
if(sum4>most)
{
most=sum4;
emost=3;
}
else
most=most;
}
}
for(int r5=4;r5<5;r5++)
{
for(int c5=0;c5<NUM_COL;c5++)
{
sum5=sum5+schedule[r5][c5];
if(sum5>most)
{
most=sum5;
emost=4;
}
else
most=most;
}
}
for(int r6=5;r6<6;r6++)
{
for(int c6=0;c6<NUM_COL;c6++)
{
sum6=sum6+schedule[r6][c6];
if(sum6>most)
{
most=sum6;
emost=5;
}
else
most=most;
}
}
for(int r7=6;r7<7;r7++)
{
for(int c7=0;c7<NUM_COL;c7++)
{
sum7=sum7+schedule[r7][c7];
if(sum7>most)
{
most=sum7;
emost=6;
}
else
most=most;
}
}
for(int r8=7;r8<8;r8++)
{
for(int c8=0;c8<NUM_COL;c8++)
{
sum8=sum8+schedule[r8][c8];
if(sum8>most)
{
most=sum8;
emost=7;
}
else
most=most;
}
}
cout<<"employee"<<emost<<" worked the most hours: "<<most<<endl;
system("PAUSE");
}


int FindEight(int schedule[][NUM_COL])
{
int count=0;
{
for(int i=0;i<NUM_ROW;i++)
{
for(int j=0;j<NUM_COL;j++)
{
if (schedule[i][j]<=8)
count ++;
else
count=count;
}
}
}
return count;

}
ive been having some trouble running this .. no errors in the program.. but its still not working
Well, you have a LOT of for loops, and some of them look useless...like the ones that run only once...wtf? I can't follow your program at all. Please revise it and use [code][/code] tags...
the loops seem fine i think i know what you are talking about in the addArray function and mostHrs function... they used to calculate the total of every row.
it seems like when i run it i have a infinite loop somewhere but i cannot find it.
Please use code tags please, its killing my eyes just looking at the code. Indentation is vital when viewing someone else's code.
Last edited on
Topic archived. No new replies allowed.