C++ program to determine the largest amount of overlapping closed intervals












0















We are supposed to do this by making an array with lower bound of 0 to upper bound of 100.
It is supposed to look like this:



Enter a list of integer delimited closed intervals, one per line, that are subintervals of [0,99].



(Enter -1 to stop)
Interval (eg: 7 10): 3 97
Interval (eg: 7 10): 5 55
Interval (eg: 7 10): 60 72
Interval (eg: 7 10): 35 82
Interval (eg: 7 10): -1
The largest number of overlapping intervals is 3.
[35,55]
[60,72]


So far I have something like this



#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int list[100] = {0};
int intervalOne; //input and output for the first interval inputted
int intervalTwo; // input and output value for the second interval inputted
int overlap; // how many of the intervals that were inputted also overlap

//Function Prototype
void initialize(int arr, int size);
void read(int arr, int size);
void print(int arr, int size);


int main ()
{
cout << "Enter a list of integer delimited closed intervals" << endl;
cout << "one per line, that are subintervals of [0,99]." << endl;
cout << " (Enter -1 to stop)" << endl;

do {
cout << "Interval (eg: 7 10) :";
cin >> intervalOne;
if (intervalOne == -1)
break;
cin >> intervalTwo;
cout << intervalOne << " " << intervalTwo << endl;
} while (intervalOne != -1);

cout << "loop has stopped with -1 input" << endl;

cout << "The largest number of overlapping intervals is " << overlap << endl;
return 0;
}


I am not certain how I'm supposed to proceed from here.










share|improve this question

























  • It seams to me like you are missing som }

    – jalazbe
    Nov 26 '18 at 22:26











  • How to proceed is really something for you to work out, as it is vague and potentially opinion-based. A good question would be more concrete, such as when your code does not do what you think it should. (Plus, questions asking for homework help must include a summary of the work you've done so far to solve the problem, and a description of the difficulty you are having solving it -- see stackoverflow.com/help/on-topic. If you can come up with a good description of your difficulty, you may be able to answer your own question.)

    – JaMiT
    Nov 26 '18 at 23:14


















0















We are supposed to do this by making an array with lower bound of 0 to upper bound of 100.
It is supposed to look like this:



Enter a list of integer delimited closed intervals, one per line, that are subintervals of [0,99].



(Enter -1 to stop)
Interval (eg: 7 10): 3 97
Interval (eg: 7 10): 5 55
Interval (eg: 7 10): 60 72
Interval (eg: 7 10): 35 82
Interval (eg: 7 10): -1
The largest number of overlapping intervals is 3.
[35,55]
[60,72]


So far I have something like this



#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int list[100] = {0};
int intervalOne; //input and output for the first interval inputted
int intervalTwo; // input and output value for the second interval inputted
int overlap; // how many of the intervals that were inputted also overlap

//Function Prototype
void initialize(int arr, int size);
void read(int arr, int size);
void print(int arr, int size);


int main ()
{
cout << "Enter a list of integer delimited closed intervals" << endl;
cout << "one per line, that are subintervals of [0,99]." << endl;
cout << " (Enter -1 to stop)" << endl;

do {
cout << "Interval (eg: 7 10) :";
cin >> intervalOne;
if (intervalOne == -1)
break;
cin >> intervalTwo;
cout << intervalOne << " " << intervalTwo << endl;
} while (intervalOne != -1);

cout << "loop has stopped with -1 input" << endl;

cout << "The largest number of overlapping intervals is " << overlap << endl;
return 0;
}


I am not certain how I'm supposed to proceed from here.










share|improve this question

























  • It seams to me like you are missing som }

    – jalazbe
    Nov 26 '18 at 22:26











  • How to proceed is really something for you to work out, as it is vague and potentially opinion-based. A good question would be more concrete, such as when your code does not do what you think it should. (Plus, questions asking for homework help must include a summary of the work you've done so far to solve the problem, and a description of the difficulty you are having solving it -- see stackoverflow.com/help/on-topic. If you can come up with a good description of your difficulty, you may be able to answer your own question.)

    – JaMiT
    Nov 26 '18 at 23:14
















0












0








0








We are supposed to do this by making an array with lower bound of 0 to upper bound of 100.
It is supposed to look like this:



Enter a list of integer delimited closed intervals, one per line, that are subintervals of [0,99].



(Enter -1 to stop)
Interval (eg: 7 10): 3 97
Interval (eg: 7 10): 5 55
Interval (eg: 7 10): 60 72
Interval (eg: 7 10): 35 82
Interval (eg: 7 10): -1
The largest number of overlapping intervals is 3.
[35,55]
[60,72]


So far I have something like this



#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int list[100] = {0};
int intervalOne; //input and output for the first interval inputted
int intervalTwo; // input and output value for the second interval inputted
int overlap; // how many of the intervals that were inputted also overlap

//Function Prototype
void initialize(int arr, int size);
void read(int arr, int size);
void print(int arr, int size);


int main ()
{
cout << "Enter a list of integer delimited closed intervals" << endl;
cout << "one per line, that are subintervals of [0,99]." << endl;
cout << " (Enter -1 to stop)" << endl;

do {
cout << "Interval (eg: 7 10) :";
cin >> intervalOne;
if (intervalOne == -1)
break;
cin >> intervalTwo;
cout << intervalOne << " " << intervalTwo << endl;
} while (intervalOne != -1);

cout << "loop has stopped with -1 input" << endl;

cout << "The largest number of overlapping intervals is " << overlap << endl;
return 0;
}


I am not certain how I'm supposed to proceed from here.










share|improve this question
















We are supposed to do this by making an array with lower bound of 0 to upper bound of 100.
It is supposed to look like this:



Enter a list of integer delimited closed intervals, one per line, that are subintervals of [0,99].



(Enter -1 to stop)
Interval (eg: 7 10): 3 97
Interval (eg: 7 10): 5 55
Interval (eg: 7 10): 60 72
Interval (eg: 7 10): 35 82
Interval (eg: 7 10): -1
The largest number of overlapping intervals is 3.
[35,55]
[60,72]


So far I have something like this



#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int list[100] = {0};
int intervalOne; //input and output for the first interval inputted
int intervalTwo; // input and output value for the second interval inputted
int overlap; // how many of the intervals that were inputted also overlap

//Function Prototype
void initialize(int arr, int size);
void read(int arr, int size);
void print(int arr, int size);


int main ()
{
cout << "Enter a list of integer delimited closed intervals" << endl;
cout << "one per line, that are subintervals of [0,99]." << endl;
cout << " (Enter -1 to stop)" << endl;

do {
cout << "Interval (eg: 7 10) :";
cin >> intervalOne;
if (intervalOne == -1)
break;
cin >> intervalTwo;
cout << intervalOne << " " << intervalTwo << endl;
} while (intervalOne != -1);

cout << "loop has stopped with -1 input" << endl;

cout << "The largest number of overlapping intervals is " << overlap << endl;
return 0;
}


I am not certain how I'm supposed to proceed from here.







c++






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 23:05









1201ProgramAlarm

17k42539




17k42539










asked Nov 26 '18 at 22:22









AsomewhatpoorstudentAsomewhatpoorstudent

42




42













  • It seams to me like you are missing som }

    – jalazbe
    Nov 26 '18 at 22:26











  • How to proceed is really something for you to work out, as it is vague and potentially opinion-based. A good question would be more concrete, such as when your code does not do what you think it should. (Plus, questions asking for homework help must include a summary of the work you've done so far to solve the problem, and a description of the difficulty you are having solving it -- see stackoverflow.com/help/on-topic. If you can come up with a good description of your difficulty, you may be able to answer your own question.)

    – JaMiT
    Nov 26 '18 at 23:14





















  • It seams to me like you are missing som }

    – jalazbe
    Nov 26 '18 at 22:26











  • How to proceed is really something for you to work out, as it is vague and potentially opinion-based. A good question would be more concrete, such as when your code does not do what you think it should. (Plus, questions asking for homework help must include a summary of the work you've done so far to solve the problem, and a description of the difficulty you are having solving it -- see stackoverflow.com/help/on-topic. If you can come up with a good description of your difficulty, you may be able to answer your own question.)

    – JaMiT
    Nov 26 '18 at 23:14



















It seams to me like you are missing som }

– jalazbe
Nov 26 '18 at 22:26





It seams to me like you are missing som }

– jalazbe
Nov 26 '18 at 22:26













How to proceed is really something for you to work out, as it is vague and potentially opinion-based. A good question would be more concrete, such as when your code does not do what you think it should. (Plus, questions asking for homework help must include a summary of the work you've done so far to solve the problem, and a description of the difficulty you are having solving it -- see stackoverflow.com/help/on-topic. If you can come up with a good description of your difficulty, you may be able to answer your own question.)

– JaMiT
Nov 26 '18 at 23:14







How to proceed is really something for you to work out, as it is vague and potentially opinion-based. A good question would be more concrete, such as when your code does not do what you think it should. (Plus, questions asking for homework help must include a summary of the work you've done so far to solve the problem, and a description of the difficulty you are having solving it -- see stackoverflow.com/help/on-topic. If you can come up with a good description of your difficulty, you may be able to answer your own question.)

– JaMiT
Nov 26 '18 at 23:14














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53490022%2fc-program-to-determine-the-largest-amount-of-overlapping-closed-intervals%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53490022%2fc-program-to-determine-the-largest-amount-of-overlapping-closed-intervals%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Lallio

Unable to find Lightning Node

Futebolista