please help

This is a discussion on please help within the C++ Programming forums, part of the General Programming Boards category; Hello! I'm new here, but for a long time following this forum. I got task for some project to do, ...

  1. #1
    Registered User
    Join Date
    Jan 2012
    Posts
    1

    please help

    Hello!

    I'm new here, but for a long time following this forum. I got task for some project to do, but I really don't know how to start. If someone can help me, I would be grateful. I didn't do anything. I don't realize this task and I don't know how to start, I don't know what I need to do in this task, or anything. I need the whole code. If anyone can solve this, please help me, it's an emergency.

    ___________________________

    You are given N open intervals on a line (the intervals do not include their endpoints). Your task is to write a program which finds the largest number of intervals that can be chosen so they don't intersect.

    INPUT:
    The first line of the standard input contains a number N (0<N<=5000), the number of intervals. The next N lines contain two integers li and ri (-10000< li < di <10000) which represent the left and right ends of the interval (1<=i<=N).

    OUTPUT:
    To the standard output in one line write the number of intervals which can be chosen so that they do not intersect.

    Input:
    4
    -1 1
    0 5
    2 3
    5 9

    Output:
    3

    P.S. The program is required to implement function, which checks whether two intervals have a common point: bool check (int beg1, int end1, int beg2, int end2).I am suffering with this for a long time and I can not resolve it, the task should be solved using the iostream library.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,823
    > I'm new here, but for a long time following this forum.
    Oh really......
    Announcements - C++ Programming

    > but I really don't know how to start.
    How did you start all your other programs?
    Or was this how you started all your other programs - dumping them on a forum?

    A program which reads the input and just prints that back to the user would be a start.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21