# Thread: How to eliminate row according to rule

1. ## How to eliminate row according to rule

When run c++ code result will be like left hand side (2673 lines)
But I want
For example, compare first line with all other
if 5 numbers or less then it will write otherwise eliminate(will not write)
if 6 numbers or above it will be eliminate and will not be written

I did This example Manualy

RESULT WILL BE LIKE THIS THREE LINES

1 2 3 4 5 6 7 8 9 10
1 2 3 4 9 11 12 13 14 15
5 6 7 8 10 11 12 13 14 15

Can you add code to my c++ program for to this

My English and c++ is poor Thanks

1: 1 2 3 4 5 6 7 8 9 10 +++
2: 1 2 3 4 5 6 7 8 9 11 -when compared with first line nine numbers are same (NO WTITE)
3: 1 2 3 4 5 6 7 8 9 12 -when compared with first line nine numbers are same (NO WRITE)
4: 1 2 3 4 5 6 7 8 10 11 -when compared with first line nine numbers are same (NO WRITE)
5: 1 2 3 4 5 6 7 8 10 12 -when compared with first line nine numbers are same (NO WRITE)
6: 1 2 3 4 5 6 7 8 10 13 -when compared with first line nine numbers are same (NO WRITE)
7: 1 2 3 4 5 6 7 8 11 12 -when compared with first line eight numbers are same (NO WRITE)
8: 1 2 3 4 5 6 7 8 11 13 -when compared with first line eight numbers are same (NO WRITE)
9: 1 2 3 4 5 6 7 8 11 14 ----
10: 1 2 3 4 5 6 7 8 12 13 ----
11: 1 2 3 4 5 6 7 8 12 14 ----
12: 1 2 3 4 5 6 7 8 12 15 ----
13: 1 2 3 4 5 6 7 8 13 14 ----
14: 1 2 3 4 5 6 7 8 13 15 ----
15: 1 2 3 4 5 6 7 8 14 15 ----
16: 1 2 3 4 5 6 7 9 10 11 -when compared with first line nine numbers are same (NO WRITE)
17: 1 2 3 4 5 6 7 9 10 12 ----
18: 1 2 3 4 5 6 7 9 10 13 ----
19: 1 2 3 4 5 6 7 9 11 12 -when compared with first line eight numbers are same (NO WRITE)
20: 1 2 3 4 5 6 7 9 11 13 ----
21: 1 2 3 4 5 6 7 9 11 14
22: 1 2 3 4 5 6 7 9 12 13 see 377. row
23: 1 2 3 4 5 6 7 9 12 14
24: 1 2 3 4 5 6 7 9 12 15
25: 1 2 3 4 5 6 7 9 13 14
26: 1 2 3 4 5 6 7 9 13 15
27: 1 2 3 4 5 6 7 9 14 15
28: 1 2 3 4 5 6 7 10 11 12
29: 1 2 3 4 5 6 7 10 11 13
30: 1 2 3 4 5 6 7 10 11 14
---
---
376: 1 2 3 4 9 10 12 13 14 15
377: 1 2 3 4 9 11 12 13 14 15 ++When compared with first line five numbers are same (WRITE)
378: 1 2 3 4 10 11 12 13 14 15 -When compared with first line five numbers are same AND COMPARED
379: 1 2 3 5 6 7 8 9 10 11 WITH 337 ROW Nine Numbers are same (NO WRITE)
380: 1 2 3 5 6 7 8 9 10 12
381: 1 2 3 5 6 7 8 9 10 13
382: 1 2 3 5 6 7 8 9 11 12
383: 1 2 3 5 6 7 8 9 11 13
see row 2669
---
---

2667: 5 6 7 8 9 10 12 13 14 15
2668: 5 6 7 8 9 11 12 13 14 15
2669: 5 6 7 8 10 11 12 13 14 15 ++When compared with first line and 377 line five numbers are same(WRITE)
2670: 5 6 7 9 10 11 12 13 14 15 When compared with first line five numbers are same AND
2671: 5 6 8 9 10 11 12 13 14 15 COMPARED WITH 337 LINE SIX Numbers are same (NO WRITE)
2672: 5 7 8 9 10 11 12 13 14 15 (No need to compaare 2669 line because it eliminated by 377 line)
2673: 6 7 8 9 10 11 12 13 14 15

When compared with first line five numbers are same
AND COMPARED WITH 337 LINE SIX Numbers are same (NO WRITE)

2. I think you should come up with a much simpler example. You seem to have only two rules (or do you? You wrote "for example"), so surely you don't need to keep repeating.

3. It's no clearer what you're trying to do now than it was 5 months ago.
How To Add A If Statment To This Code - C And C++ | Dream.In.Code

Before you copy/paste yourself into a 10-level deep monstrosity, make a simplified version which is a lot easier on the eye, and might help us figure out what it is you actually want (see also The XY Problem ).
Code:
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
const int NMAX = 5; // was 15;

int s = 0;

ostream & out = cout;                // for screen

for ( int a = 1; a <= NMAX - 2; a++ )
{
for ( int b = a + 1; b <= NMAX - 1; b++ )
{
for ( int c = b + 1; c <= NMAX; c++ )
{
// now what?
}
}
}
}
Make a small program which demonstrates the problem and actually compiles.
Dumping a 100+ line mess with no description as to what (or why) isn't going to work out for you.

Such questions come to mind as
- Why only the first two loops have NMAX-2 and NMAX-1 ?
- What is the relationship between NMAX and how many nested loops you have?