Please review my code here in C... there are errors occurring and I'm not sure why. InputInput will begin with a line containing 1 integer, n (1 ≤ n ≤ 500,000), representing the number of groups to process. The following n lines will each contain 3 integers: s, a, and p (1 ≤ s ≤ 1,000,000; 1 ≤ a ≤ 1,000,000,000; 1 ≤ p ≤ 1,000,000) representing the group size, arrival time, and processing time respectively. Output should contain 1 integer representing the sum time taken by all people that waited in line.           Example: Sample Input: 4 1 4 10 1 2 10 1 1 10 1 3 10 Output: 56 3 2 10 10 3 9 1 1 1 20 Output: 65   Code below: #include #include #include #include #include usingnamespace std; int main() { while(true){ cout<<"\nEnter visitor's data or input xx to stop\n"; string s; getline(cin,s);// Enter the new data line if(s=="xx")//If entered value is xx then stop break; stringstream ss(s);//Conersion of string to numbers of visitors vectorvisitor_count; int x; while(ss>>x){ if(x==888)//If number is sentinel value then stop break; else visitor_count.push_back(x); } string time;// To input string value ss>>time; int total_visitors=0;//To sum up total visitors for(int i=0;i

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please review my code here in C... there are errors occurring and I'm not sure why.

InputInput will begin with a line containing 1 integer, n (1 ≤ n ≤ 500,000), representing the number of groups
to process. The following n lines will each contain 3 integers: s, a, and p (1 ≤ s ≤ 1,000,000; 1 ≤ a ≤
1,000,000,000; 1 ≤ p ≤ 1,000,000) representing the group size, arrival time, and processing time
respectively.
Output should contain 1 integer representing the sum time taken by all people that waited in line.
 
 
 
 
 
Example:
Sample Input:
4
1 4 10
1 2 10
1 1 10
1 3 10
Output: 56
3
2 10 10
3 9 1
1 1 20
Output: 65
 
Code below:

#include<iostream>
#include<string.h>
#include<sstream>
#include<vector>
#include <stdio.h>

usingnamespace std;

int main()

{

while(true){

cout<<"\nEnter visitor's data or input xx to stop\n";

string s;

getline(cin,s);// Enter the new data line

if(s=="xx")//If entered value is xx then stop

break;

stringstream ss(s);//Conersion of string to numbers of visitors

vector<int>visitor_count;

int x;
while(ss>>x){

if(x==888)//If number is sentinel value then stop

break;

else

visitor_count.push_back(x);

}

string time;// To input string value

ss>>time;

int total_visitors=0;//To sum up total visitors

for(int i=0;i<visitor_count.size();i++){

cout<<visitor_count[i]<<" New visitors entered.\n";

total_visitors += visitor_count[i];

}

cout<<"By "<<time<<<"," <<total_visitors<<" new visitors entered the Park\n";

}

return0;
}

Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education