1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <ctime>
void SortedArray (int x, int size);
void Display (string x, int size);
void ageArray (int y[], int size);
void sortedAge(int y[], int size);
void sortedName(string x, int size);
void sortedUP (string x, int size, char z);
using namespace std;
int main()
{
time_t p;
time(&p);
cout << ctime(&p) << endl;
int age[5] = { 22, 33, 11, 16, 10 };
string name[4] = { "Bill", "Adam", "Mary", "David" };
char c;
ageArray(age, 5);
Display(name, 4);
sortedAge(age, 5);
sortedName(name, 4);
sortedUP(name, 4, c);
system("PAUSE");
return 0;
}
void Display(string x, int size)
{
for (int i = 0; i < size; i++)
{
cout << x[i] << " ";
}
}
void ageArray(int y[], int size)
{
for (int i = 0; i < size; i++)
{
cout << y[i] << " ";
}
}
void sortedAge(int y[], int size)
{
sort(y, y+size);
for (int i = 0; i < size; i++)
{
cout << y[i] << " ";
}
}
void sortedName(string x, int size)
{
sort(x, x+4);
for (int i = 0; i < size; i++)
{
cout << x[i] << " ";
}
}
|