In picture one - Line 12 - int main(), there is a green squiggly line under the word main picture 2 - My output is not generated. I showed how when you input the number of elements for arrays and click enter the numbers do not appear, then I clicked enter more times for you to see nothing happened whrn I clicked enter until I input numbers myself. Thank you I hope this is what you were asking for. I us Visual Studio 2019, C++ console for Windows 10. If possible, please help me. heck_circle Expert Answer thumb_up thumb_down Step 1 Required: Below this question was asked and answered with the output to prove it works from an expert, but for some reason when I put the code into my MS Visual Studio 2019, C++ console for Windows 10 there appeared to be a warning at line 6 - int main(){. I received a warning under the word main (green squiggly line) and my output don't work for me as yours did for you. Do you think you can help me please. Step 2 Dear student below is screenshot from the code, in VS Code. it is running fine and showing no Error. from your question, since you have not posted the exact error. it will be difficult to troubleshoot. please post your exact error code screenshot. Code: #include #include #include using namespace std; vector mode(int[], int); int main() { int n, a[100000]; vector answer; vector::iterator it; cout << "Enter number of elements in array:" << endl; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } answer = mode(a, n); if (answer.size() == 0) { cout << "There are no modes" << endl; } else if (answer.size() == 1) { cout << "Mode is:" << endl; } else { cout << "Modes are:" << endl; } for (it = answer.begin(); it != answer.end(); it++) { cout << *it << " "; } } vector mode(int a[], int n) { int greater = 0; vector v; map m1, m2; for (int i = 0; i < n; i++) { m1[a[i]]++; if (m1[a[i]] > greater) greater = m1[a[i]]; } for (int i = 0; i < n; i++) { if (m1[a[i]] == greater && greater > 1 && m2[a[i]] != 1) { v.push_back(a[i]); m2[a[i]] = 1; } } return v; } Output:
In picture one - Line 12 - int main(), there is a green squiggly line under the word main picture 2 - My output is not generated. I showed how when you input the number of elements for arrays and click enter the numbers do not appear, then I clicked enter more times for you to see nothing happened whrn I clicked enter until I input numbers myself. Thank you I hope this is what you were asking for. I us Visual Studio 2019, C++ console for Windows 10. If possible, please help me. heck_circle Expert Answer thumb_up thumb_down Step 1 Required: Below this question was asked and answered with the output to prove it works from an expert, but for some reason when I put the code into my MS Visual Studio 2019, C++ console for Windows 10 there appeared to be a warning at line 6 - int main(){. I received a warning under the word main (green squiggly line) and my output don't work for me as yours did for you. Do you think you can help me please. Step 2 Dear student below is screenshot from the code, in VS Code. it is running fine and showing no Error. from your question, since you have not posted the exact error. it will be difficult to troubleshoot. please post your exact error code screenshot. Code: #include #include #include using namespace std; vector mode(int[], int); int main() { int n, a[100000]; vector answer; vector::iterator it; cout << "Enter number of elements in array:" << endl; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } answer = mode(a, n); if (answer.size() == 0) { cout << "There are no modes" << endl; } else if (answer.size() == 1) { cout << "Mode is:" << endl; } else { cout << "Modes are:" << endl; } for (it = answer.begin(); it != answer.end(); it++) { cout << *it << " "; } } vector mode(int a[], int n) { int greater = 0; vector v; map m1, m2; for (int i = 0; i < n; i++) { m1[a[i]]++; if (m1[a[i]] > greater) greater = m1[a[i]]; } for (int i = 0; i < n; i++) { if (m1[a[i]] == greater && greater > 1 && m2[a[i]] != 1) { v.push_back(a[i]); m2[a[i]] = 1; } } return v; } Output:
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
Related questions
Question
In picture one - Line 12 - int main(), there is a green squiggly line under the word main
picture 2 - My output is not generated. I showed how when you input the number of elements for arrays and click enter the numbers do not appear, then I clicked enter more times for you to see nothing happened whrn I clicked enter until I input numbers myself. Thank you I hope this is what you were asking for. I us Visual Studio 2019, C++ console for Windows 10.
If possible, please help me.
heck_circle
Expert Answer
thumb_up
thumb_down
Step 1
Required:
Below this question was asked and answered with the output to prove it works from an expert, but for some reason when I put the code into my MS Visual Studio 2019, C++ console for Windows 10 there appeared to be a warning at line 6 - int main(){. I received a warning under the word main (green squiggly line) and my output don't work for me as yours did for you.
Do you think you can help me please.
Step 2
Dear student below is screenshot from the code, in VS Code. it is running fine and showing no Error. from your question, since you have not posted the exact error. it will be difficult to troubleshoot. please post your exact error code screenshot.
Code:
#include <iostream>
#include <vector >
#include <map>
using namespace std;
vector<int> mode(int[], int);
int main()
{
int n, a[100000];
vector<int> answer;
vector<int>::iterator it;
cout << "Enter number of elements in array:" << endl;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
answer = mode(a, n);
if (answer.size() == 0)
{
cout << "There are no modes" << endl;
}
else if (answer.size() == 1)
{
cout << "Mode is:" << endl;
}
else
{
cout << "Modes are:" << endl;
}
for (it = answer.begin(); it != answer.end(); it++)
{
cout << *it << " ";
}
}
vector<int> mode(int a[], int n)
{
int greater = 0;
vector<int> v;
map<int, int> m1, m2;
for (int i = 0; i < n; i++)
{
m1[a[i]]++;
if (m1[a[i]] > greater)
greater = m1[a[i]];
}
for (int i = 0; i < n; i++)
{
if (m1[a[i]] == greater && greater > 1 && m2[a[i]] != 1)
{
v.push_back(a[i]);
m2[a[i]] = 1;
}
}
return v;
}
Output:
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
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.Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education