This is one part of my program, I need a loop that checks through the input(specifically the agent numbers) and then outputs the agent numbers that aren't in the input, from 1 to 20(because there should only be 20 agent).
My input is :
1 3 250.00
2 0 0
15 1 1000.00
3 4 300.00
12 2 500.00
1 2 300.00
3 4 115.00
21 3 400.00
-1 4 250.00
15 1 200.00
9 5 -150.00
18 2 140.00
13 2 550.00
the first numbers are the agent numbers so 1 , 2 ,15 are agent numbers and out output for agents who didnt participate are : 2 , 5 , 6 , 7, 8, 9, 10 , 11 , 14 , 16 , 17 ,19 20
this is the code ive wrote but its not working , help would be appreciated
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
void not_part()
{
ins.open(in_file);
int i=0;
int sum=0;
cout<<"AGENTS WHO DID NOT PARTICIPATE IN THE CAMPAIGN"<<endl;
cout<<fixed<<showpoint;
cout<<setprecision(2);
while(!ins.eof())
{
ins>>agent[i]>>sales[i]>>value[i];
amount[i]=sales[i]*value[i];
for(int j=1; j<=20; j++)
{
for(int t=0; t<=count; t++)
if(j!=agent[t])
{
sum+=1;
if(sum==count)
{
cout<<j<<" ";
sum=0;
}
}
}
i++;
}
cout<<endl;
ins.clear();
ins.close();
}
|