# Thread: When run program how to eliminate line by rule

1. ## When run program how to eliminate line by rule

When run program compare line one and line two, if line two numbers 9 are same as line one then it WILL NOT write otherwise write

line one 1 2 3 4 5 6 7 8 9 10
line two 1 2 3 4 5 6 7 8 9 11

as you see above 9 numbers are same thats why line two will not be written

then compare line one and line three again if 9 numbers are same also will not line three and so on

result willl be
line one 1 2 3 4 5 6 7 8 9 10
line seven 1 2 3 4 5 6 7 8 11 12
line twelwe 1 2 3 4 5 6 7 8 13 14

and so on

I mean
when program finished if 9 numbers same from written numbers
it will not write

Code:
```#include <iostream>
#include <fstream>
using namespace std;

int main()
{
const int NMAX = 14;

int s = 0;

//Choose ONE of the following
//ofstream out( "outputtt.txt" ); // for file
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++ )
{
for ( int d = c + 1; d <= NMAX; d++ )
{
for ( int e = d + 1; e <= NMAX; e++ )
{
for ( int f = e + 1; f <= NMAX; f++ )
{
for ( int g = f + 1; g <= NMAX; g++ )
{
for ( int h = g + 1; h <= NMAX; h++ )
{
for ( int i = h + 1; i <= NMAX; i++ )
{
for ( int j = i + 1; j <= NMAX; j++)
{

if(i != j - 4);
else{
continue;
}
if(i != j - 5);
else{
continue;
}
if(i != j - 6);
else{
continue;
}
if(i != j - 7);
else{
continue;
}
if(i != j - 8);
else{
continue;
}
if(i != j - 9);
else{
continue;
}
if(i != j - 10);
else{
continue;
}
if(i != j - 11);
else{
continue;
}
if(i != j - 12);
else{
continue;
}
if(i != j - 13);
else{
continue;
}
if(i != j - 14);
else{
continue;
}

if(g != h - 4);
else{
continue;
}
if(g != h - 5);
else{
continue;
}
if(g != h - 6);
else{
continue;
}
if(g != h - 7);
else{
continue;
}
if(g != h - 8);
else{
continue;
}
if(g != h - 9);
else{
continue;
}
if(g != h - 10);
else{
continue;
}
if(g != h - 11);
else{
continue;
}
if(g != h - 12);
else{
continue;
}
if(g != h - 13);
else{
continue;
}
if(g != h - 14);
else{
continue;
}
if(g != h - 15);
else{
continue;
}
if(g != h - 16);
else{
continue;
}
if(g != h - 17);
else{
continue;
}
if(g != h - 18);
else{
continue;
}
if(g != h - 19);
else{
continue;
}
if(g != h - 20);
else{
continue;
}
if(g != h - 21);
else{
continue;
}
if(g != h - 22);
else{
continue;
}
if(g != h - 23);
else{
continue;
}
if(g != h - 24);
else{
continue;
}
if(g != h - 25);
else{
continue;
}
if(g != h - 26);
else{
continue;
}
if(g != h - 27);
else{
continue;
}
if(g != h - 28);
else{
continue;
}
if(g != h - 29);
else{
continue;
}
if(g != h - 30);
else{
continue;
}
if(g != h - 31);
else{
continue;
}
if(g != h - 32);
else{
continue;
}
if(g != h - 33);
else{
continue;
}
if(g != h - 34);
else{
continue;
}
if(g != h - 35);
else{
continue;
}
if(g != h - 36);
else{
continue;
}
if(g != h - 37);
else{
continue;
}
if(g != h - 38);
else{
continue;
}
if(g != h - 39);
else{
continue;
}
if(g != h - 40);
else{
continue;
}
if(g != h - 41);
else{
continue;
}
if(g != h - 42);
else{
continue;
}
if(g != h - 43);
else{
continue;
}
if(g != h - 44);
else{
continue;
}
if(g != h - 45);
else{
continue;
}
if(g != h - 46);
else{
continue;
}
if(g != h - 47);
else{
continue;
}
if(g != h - 48);
else{
continue;
}
if(g != h - 49);
else{
continue;
}
if(g != h - 50);
else{
continue;
}
if(g != h - 51);
else{
continue;
}
if(g != h - 52);
else{
continue;
}
if(g != h - 53);
else{
continue;
}
if(g != h - 54);
else{
continue;
}
if(g != h - 55);
else{
continue;
}
if(g != h - 56);
else{
continue;
}
if(g != h - 57);
else{
continue;
}
if(g != h - 58);
else{
continue;
}
if(g != h - 59);
else{
continue;
}
if(g != h - 60);
else{
continue;
}
if(g != h - 61);
else{
continue;
}
if(g != h - 62);
else{
continue;
}
if(g != h - 63);
else{
continue;
}
if(g != h - 64);
else{
continue;
}
if(g != h - 65);
else{
continue;
}
if(g != h - 66);
else{
continue;
}
if(g != h - 67);
else{
continue;
}
if(g != h - 68);
else{
continue;
}
if(g != h - 69);
else{
continue;
}
if(g != h - 70);
else{
continue;
}
if(g != h - 71);
else{
continue;
}
if(g != h - 72);
else{
continue;
}
if(g != h - 73);
else{
continue;
}
if(g != h - 74);
else{
continue;
}
if(g != h - 75);
else{
continue;
}
if(g != h - 76);
else{
continue;
}
if(g != h - 77);
else{
continue;
}
if(g != h - 78);
else{
continue;
}
if(g != h - 79);
else{
continue;
}
if(g != h - 80);
else{
continue;
}

if(e != f - 4);
else{
continue;
}
if(e != f - 5);
else{
continue;
}
if(e != f - 6);
else{
continue;
}
if(e != f - 7);
else{
continue;
}
if(e != f - 8);
else{
continue;
}
if(e != f - 9);
else{
continue;
}
if(e != f - 10);
else{
continue;
}
if(e != f - 11);
else{
continue;
}
if(e != f - 12);
else{
continue;
}
if(e != f - 13);
else{
continue;
}
if(e != f - 14);
else{
continue;
}

if(c != d - 4);
else{
continue;
}
if(c != d - 5);
else{
continue;
}
if(c != d - 6);
else{
continue;
}
if(c != d - 7);
else{
continue;
}
if(c != d - 8);
else{
continue;
}
if(c != d - 9);
else{
continue;
}
if(c != d - 10);
else{
continue;
}
if(c != d - 11);
else{
continue;
}
if(c != d - 12);
else{
continue;
}
if(c != d - 13);
else{
continue;
}
if(c != d - 14);
else{
continue;
}

if(a != b - 4);
else{
continue;
}
if(a != b - 5);
else{
continue;
}
if(a != b - 6);
else{
continue;
}
if(a != b - 7);
else{
continue;
}
if(a != b - 8);
else{
continue;
}
if(a != b - 9);
else{
continue;
}
if(a != b - 10);
else{
continue;
}
if(a != b - 11);
else{
continue;
}
if(a != b - 12);
else{
continue;
}
if(a != b - 13);
else{
continue;
}
if(a != b - 14);
else{
continue;
}

int n = 100 * a + 10 * b + c + d + e + f + g + h + i + j;

s++;

//out << s << ": " << n << '\n';
out << s << ": " << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << " " << h << " " << i << " " << j << '\n';

}
}
}
}
}
}
}
}
}
}

}```

2. I think you're overcomplicating your program. You should find the index of 9 in the first input line, then check if the number at that same index in subsequent lines is also a 9. You don't need nested loops for this (except maybe to read the individual numbers).

As it stands, your code has really poor style:
• You desperately need to indent your code properly.
• Even with indentation, a 10 level deep directly nested loop should have hinted to you that you have a wrong approach.
• Granted, it is usually alright to have single letter variable names for loop indices, but when you have so many nested loops, this becomes a WTF where are the descriptive names moment.
• Likewise, you have too many magic numbers in your code.
• Considered use of continue to skip to the start of a loop is okay, but here you have so many it looks like misuse.
• A rule of thumb is to look at the number of lines of your functions. If they aren't merely defining data, then when your function length starts exceeding 100 lines (some would put a lower threshold; it can depend on your indent style), you're probably doing something wrong, so you should try a different approach if you cannot break up your functions into smaller ones that do one thing and do it well.

3. Thank you,

I am not good in c++