// Calculate the quarters of a set of integers
#include <iostream>
#include <vector>
#include <algorithm>
#include <conio.h>
using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::sort;
int main()
{
// Ask for a set of integers
cout << "Please input a set of integers: "
<< endl;
// Read the set of integers
// x is the variable to write
int x;
// int_set is the set of integers to write
vector<int> int_set;
while (cin >> x)
{
int_set.push_back(x);
}
// Check if the integer set is vacant
typedef std::vector<int>::size_type vec_sz;
vec_sz size = int_set.size();
if (size == 0)
cout << "There are no data. "
<< "Please try again. ";
// Sort
sort (int_set.begin(), int_set.end());
// The set of integers multiply 1/4
vector<double> int_set_quarter;
cout << "The quarters of the set of integers are: ";
for (int i = 0; i != size; ++i)
{
int_set_quarter[i] = 1/4 * int_set[i];
cout << int_set_quarter[i];
cout << endl;
}
getch();
return 0;
}
If you run, then it will collapse...