I'm trying to understand what you mean. As an example...
Say you have a list of numbers.
3,5,7,1,89,4,6,3:
First quarter: 89, 7
Second quarter: 6, 5
Thrid quarter: 4, 3
Fourth quarter: 3, 1
Is this what you mean? In order for the
list to be split into quarters the
total number of elements in the list
has to be a exactly divisible by 4.
Let's say I had nine instead of eight
elements- using the first example again.
3,5,7,1,89,4,6,3,12
First quarter: 89, 12
second quarter:7,6
Third quarter:5,4
Fourth quarter:3,3
Left over(s): 1
What you intend to do with the left overs
is up to you. But clearly, you cannot divide
a list of nine elements evenly into four.
I have written a code for you which does as you ask, if indeed I
have interpreted what you mean correctly. It should be easy to
understand and you may want to use a function to call each quarter.
Code:
#include<iostream>
using namespace std;
int main()
{
int array[81];
int count=0;
int terminate=0;
// store numbers inside an array
while (terminate==0)
{
cout<<"Enter number or 0 to quit:";
cin>>array[count];
if(array[count]==0)
{
terminate=1;
}
count++;
}
// Find out what each quarter of the total list is
// Note it has to be 'int' rather than 'float'
int quarter=(count-1)/4;
int quarter_2= 2*quarter;
int quarter_3= 3*quarter;
int quarter_4= 4*quarter;
int left_over= (count-1)-quarter_4; // if the list is not divisible by 4
//Begin to order list of numbers in descending order
//Use method similar to bubble sort
for (int a=0; a<count-1; a++)
{
for (int b=0; b<count-1; b++)
{
if(array[a]>array[b])
{
int temp,temp_2;
temp=array[b];
temp_2=array[a];
array[b]=temp_2;
array[a]=temp;
}
}
}
// You can put this into a function if you want
cout<<""<<endl;
cout<<""<<endl;
cout<<"First quarter:"<<endl;
for (int m=0; m<quarter; m++)
{
cout<<array[m]<<",";
}
cout<<""<<endl;
cout<<"Second quarter:"<<endl;
for (int n=quarter; n<quarter_2; n++)
{
cout<<array[n]<<",";
}
cout<<""<<endl;
cout<<"Third quarter:"<<endl;
for (int o=quarter_2; o<quarter_3; o++)
{
cout<<array[o]<<",";
}
cout<<""<<endl;
cout<<"Fourth quarter:"<<endl;
for (int p=quarter_3; p<quarter_4; p++)
{
cout<<array[p]<<",";
}
cout<<""<<endl;
cout<<"Left overs:"<<endl;
for (int q=quarter_4; q<(quarter_4)+left_over; q++)
{
cout<<array[q]<<",";
}
cout<<""<<endl;
int stop;
cin>>stop;
}