Thread: How to eliminate row according to rule

  1. #1
    Registered User
    Join Date
    Apr 2019
    Posts
    3

    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)
    Attached Files Attached Files

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,150
    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.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,485
    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?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. When run program how to eliminate line by rule
    By avnitoto in forum C++ Programming
    Replies: 2
    Last Post: 04-22-2019, 12:56 AM
  2. help...! how to eliminate these erros in my code?
    By Carlies in forum C Programming
    Replies: 3
    Last Post: 10-05-2015, 05:47 AM
  3. Eliminate title
    By ulti-killer in forum C Programming
    Replies: 8
    Last Post: 06-17-2012, 08:38 AM
  4. Simpson's rule and Trapezoidal rule from fixed array
    By timwonderer in forum C++ Programming
    Replies: 1
    Last Post: 12-02-2010, 03:14 PM
  5. new to C...need to eliminate whitespace
    By cakestler in forum C Programming
    Replies: 7
    Last Post: 02-02-2009, 12:41 PM

Tags for this Thread