This repository has been archived by the owner on Oct 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyStaticArray.cpp
61 lines (49 loc) · 1.5 KB
/
MyStaticArray.cpp
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
// Lab 5a, Write A Static Array Class Template
// Programmer: Minos Park
// Editor(s) used: Sublime Text 2
// Compiler(s) used: G++
#include <iostream>
using namespace std;
#include "StaticArray.h"
char buf[100];
Array<int, 100> data;
int main()
{
// print my name and this assignment's title
cout << "Lab 5a, Write A Static Array Class Template";
cout << "Programmer: Minos Park\n";
cout << "Editor(s) used: Sublime Text 2\n";
cout << "Compiler(s) used: G++\n";
cout << "File: " << __FILE__ << endl;
cout << "Complied: " << __DATE__ << " at " << __TIME__ << endl << endl;
int select;
while(data.size()<=data.capacity())
{
cout << "input data: ";
cin >> buf;
if(buf[0]=='q' || buf[0]=='Q')
{
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << endl << "Data Structure size: " << data.size() << endl;
cout << "All entered values: ";// << data[i] << ", "
for (int i = 0; i < data.size(); i++)
{
cout << data[i] << " ";
}
cout << endl << endl;
while(1)
{
cout << "Search query: ";
cin >> buf;
if (buf[0]=='q' || buf[0]=='Q') return 0;
select = atoi(buf);
cin.ignore(numeric_limits<streamsize>::max(), '\n');
int temp = data.lsearch(select);
cout << "Found data: data[" << temp << "] = " << data[temp] << endl << endl;
}
}
select = atoi(buf);
cin.ignore(numeric_limits<streamsize>::max(), '\n');
data[data.size()] = select;
}
}