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
|
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
/*
*/
void sort(int, int);
void swap(int, int);
int indexx(int, int, int);
int main ()
{
//declarations
ifstream text1;
ifstream text2;
ofstream text3;
string line;
string word;
string array[21];
int loop=0;
int number = 21;
text1.open("file1.txt");
getline (text1,line, '\0');
text2.open("file2.txt");
getline (text2,word, '\0');
array[loop] = line + word;
cout << array[loop] << endl;
sort(array[], number);
text3.open("file3.txt");
text3 << array[loop];
}
void sort(int array[], int number)
{
int b;
for (int index = 0; index < number - 1; index++)
{
b = indexx(array[], index, number);
swap(array[index], array[indexx]);
}
}
void swap(int& v1, int& v2)
{
int temp;
temp = v1;
v1 = v2;
v2 = temp;
}
int indexx(const int array[], int start, int number)
{
int min = array[start];
int dex = start
for (int index = start + 1; index < number; index++)
if (array[index] < min)
{
min = array[index];
dex = index;
}
return dex;
|