answersLogoWhite

0


Best Answer

#include<iostream>

#include<vector>

#include<list>

#include<map>

#include<time.h>

int main()

{

srand ((unsigned)time(nullptr));

// Create a list of 100 values in the range 0 to 9.

std::cout << "Number list:\t";

std::list<size_t> numbers;

for (size_t i=0; i<100; ++i)

{

numbers.push_back (rand()%10);

std::cout << numbers.back() << ' ';

}

std::cout << '\n' << std::endl;

// Determine position(s) of each number.

std::map<size_t, std::vector<size_t>> map;

size_t pos = 0;

for (auto it=numbers.begin(); it!=numbers.end(); ++it)

map[*it].push_back(pos++);

// Print number, frequency and position(s).

for (auto it=map.begin(); it!=map.end(); ++it)

{

std::cout << "Number:\t\t" << (*it).first << std::endl;

std::cout << "Frequency:\t" << (*it).second.size() << std::endl;

std::cout << "Postions:\t";

const std::vector<size_t>& positions = (*it).second;

for (auto it=positions.begin(); it!=positions.end(); ++it)

std::cout << (*it) << ' ';

std::cout << '\n' << std::endl;

}

}

User Avatar

Wiki User

7y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C plus plus program for displaying position and frequency of a number in the given list?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

A computer programmer wrote a program that adds two numbers The programmer ran the program and observed that when 5 is added to 8 the result is the character m Explain why this program is behaving?

This is happening because when the programmer is displaying the number, it is being displayed as a character with a decoding process of a = 1, b = 2, etc. 5 + 8 = 13 = m


Is frequency same as pulse?

NO; frequency is the number of cycles per second or micro second. Pulse is the number of pulses per second in a pulsed Radar


What term is used to define the number of cycles completed by a signal in one second?

Its frequency, in Hertz.


How is an ammeter connected to reduce frequency errors?

Connecting an ammeter does not reduce the frequency errors.


A c program for multiplication of two integers a and b?

/*PROGRAM TO ACCEPT TWO NUMBERS FROM THE USER AND PRINT THEIR MULTIPLICATION. */ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main() { int a, b, c; // Declaration of Variables. Variables 'a' &amp; 'b' to hold first &amp; second number. And 'c' to hold result. clrscr(); // To clear the output screen every time program is executed. printf("\n Enter the first number : "); scanf("%d", &amp;a); // To accept the first number. printf("\n Enter the second number : "); scanf("%d", &amp;b); // To accept the second number. c = a*b; // Logic to get the product of the entered two numbers. printf("\n Multiplication of %d &amp; %d = %d", a, b, c); // Displaying result. getch(); // To hold the output screen. }

Related questions

What type of graph is best suited for displaying the range and frequency distribution of the number of apples sold at a produce stand while still showing the number of apples bought by individual cust?

stem-and-leaf plot


How do you program a regency act t16k?

Press the channel number you want to program, then press, pr, now inter the frequency. then press channel number again. Good luck Bill Rusher warusher@ftc-i.net


How do you program Z 45 regency scanner?

To program the Regency Z30 TURN UNIT "ON" 1. Press "MANUAL" 2. Enter the frequency you want, example 162.475 3. Press "ENTER" The display will show "Ch_" with the _ (underscore) flashing 4. Enter the number of the channel where you wish to store the frequency. Note: channels 1 thru 9 must have a zero before them, example 01, 02,........ 09 If you want to add more frequencies at this time, got to step 2. To lock out a channel, press "SCAN" and while the unit is scanning,enter the channel number. Repeat this action to unlock a channel. To increase or decrease the scanning rate, press the "SPEED / ENTER" key while the unit is scanning. To create a delay after a transmission, press the "DELAY" key while the unit is scanning. You can change the display by pressing the "CHANNEL / DISPLAY" key. There are 3 choices: display only the channel number, only the frequency,or alternate displaying the channel number and the frequency.


The number of times a data occurs?

the answer is frequency. the answer is frequency.


what type graph is best suited for displaying the average number of pets for families in different income ranges?

Almost any: column, bar, line, scatter, pictogram. A histogram is OK but the frequency density must be calculated on the basis of the number of families in each income range and not the income range itself.


A computer programmer wrote a program that adds two numbers The programmer ran the program and observed that when 5 is added to 8 the result is the character m Explain why this program is behaving?

This is happening because when the programmer is displaying the number, it is being displayed as a character with a decoding process of a = 1, b = 2, etc. 5 + 8 = 13 = m


How do you manualy program pro-197 scanner?

Programming a PRO-70 radio scannerPress the PGM buttonEnter the channel number desired to store the frequencyPress the PGMEnter the frequency you wish to program into the scannerPress the E/L-OUT button to program the frequency into the scannerAfter the last step the The channel number stops flashing, indicating that theselected channel is stored.To program another channel repeat steps 2 through 4.For an expanded description as well as the complete owner's manual in PDF format visit the link provided below in the Related Links section.


What is the frequency in a frequency table?

The frequency in a frequency table is the number of occurrences within each class width. The total frequency is the sum of all frequency's within all the classes.


In a frequency distribution what is the number of observation in a class called?

Class Frequency


The number of cycles per second describes the waves'?

frequency.


What is the number of waves that pass a point per second?

Frequency


What is the number of crests and troughs that pass a point per second?

That is twice the frequency. Frequency is equal to the number of complete cycles which pass a point per second.