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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
/*
Programmer: Galen Casstevens
UserID: gcasstev
Section: 001
Assignment: Program 4
Purpose: This program will implement pattern matching and sorting techniques. The user will be given the choice to either implement a pattern matching or sorting technique. The program will continue running until the user decides to exit.
*/
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
void input(int [], int &);
void output(int [], int &);
int main()
{
//This is my personal information that will be displayed to the user.
cout << "Programmer: Galen Casstevens " << endl;
cout << "UserID: gcasstev " << endl;
cout << "Section: 001 " << endl;
cout << "Assignment: Program 4 " << endl;
cout << "Purpose: This program will implement pattern matching and sorting techniques. The user will be given the choice to either implement a pattern matching or sorting technique. The program will continue running until the user decides to exit. " << endl;
cout << endl;
cout << endl;
char patternsOrSorting;
char exit = 'n';
char text[5000];
int sorting[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int Size = 0;
input (sorting, Size);
cout << endl;
cout << "These are the newly generated numbers: ";
output (sorting, Size);
cout << endl;
srand(time(NULL));
while(exit == 'n' || exit == 'N')
{
cout << "Would you like to implement a pattern matching technique or a sorting technique (enter 'P' for pattern matching or 'S' for sorting)?: ";
cin >> patternsOrSorting;
cout << endl;
if(patternsOrSorting == 'p' || patternsOrSorting == 'P')
{
cout << "Enter text: ";
cin >> text;
cout << endl;
}
cout << "Would you like to exit the program?: ?";
cin >> exit;
cout << endl;
}
return 0;
}
void input (int sorting[], int Size)
{
int i = 0;
for(i=0; i<Size; i++)
{
sorting[i] = rand()%100+1;
}
}
void output (int sorting[], int Size)
{
int j = 0;
for (j = 0; j < Size; j++)
{
cout << sorting[j] << " ";
}
}
|