#include
#include
#include
#include
#include
#include
using namespace std;
int main()
{
setlocale(LC_ALL, "Russian");
vector::const_iterator iter;
cout << "Создание листа очков" << endl;
vector scores;
scores.push_back(1500);
scores.push_back(3500);
scores.push_back(7500);
cout << "\nHigh Score" << endl;
for (iter = scores.begin(); iter != scores.end(); iter++)
{
cout << *iter << endl;
}
int score;
bool validScore = false;
do
{
cout << "\nFinding a score" << endl;
cout << "Enter a score to find (1500, 3500, 7500): ";
cin >> score;
iter = find(scores.begin(), scores.end(), score);
if (iter != scores.end())
{
cout << "Score found.\n";
validScore = true;
}
else
{
cout << "Score not found. Please enter one of the valid scores.\n";
}
} while (!validScore);
cout << "\nRandomizing score" << endl;
srand(time(0));
random_shuffle(scores.begin(), scores.end());
for (iter = scores.begin(); iter != scores.end(); iter++)
{
cout << *iter << endl;
}
cout << "Sorting score" << endl;
sort(scores.begin(), scores.end());
for (iter = scores.begin(); iter != scores.end(); iter++)
{
cout << *iter << endl;
}
return 0;
}
#include <iostream>
#include <string>
#include <ctime>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
setlocale(LC_ALL, "Russian");
vector<int>::const_iterator iter;
cout << "Создание листа очков" << endl;
vector <int>scores;
scores.push_back(1500);
scores.push_back(3500);
scores.push_back(7500);
cout << "\nHigh Score" << endl;
for (iter = scores.begin(); iter != scores.end(); iter++)
{
cout << *iter << endl;
}
{
cout << "\nFinding a score" << endl;
int score;
cout << "\nEnter a score to find";
cin >> score;
iter = find(scores.begin(), scores.end(), score);
if (iter != scores.end())
{
cout << "Score found. \ n";
}
else
{
cout << "Score not found. \ n";
}
cout << "\nRandomizing score" << endl;
srand(time(0));
random_shuffle(scores.begin(),scores.end());
for (iter = scores.begin(); iter != scores.end(); iter++)
{
cout << *iter << endl;
}
cout << "Sorting score" << endl;
sort(scores.begin(),scores.end());
for (iter = scores.begin(); iter != scores.end(); iter++)
{
cout << *iter << endl;
}
return 0;
}