## Wing Project 1

0 likes • Oct 31, 2021
C++

## More C++ Posts

#include <bits/stdc++.h>#define MAXSIZE 50000#define INF 100000
using namespace std;
bool visited[MAXSIZE]; //Checks if a node is visited or not in BFS and DFSbool isConnected = true; //Checks if the input graph is connected or not
int dist[MAXSIZE], discover[MAXSIZE], finish[MAXSIZE]; //Distance for BFS, in time and out time for DFSint t = 1; //Time used for DFSint u, v, i, j, k, N = 0;
stack<int> st; //Stack for TopSort
multiset<pair<int, int>> s; //collection of pairs to sort by distancepair<int, int> current; //pointer variable to a position in the multiset
void BFS(){	queue<int> q; //queue for BFS	q.push(1); //pushing the source	dist[1] = 0; //assign the distance of source as 0	visited[1] = 1; //marking as visited		while(!q.empty())	{	u = q.front();	q.pop();
if(!visited[v]) //if not visited, update the distance and push onto queue	{	visited[v] = 1;	dist[v] = dist[u]+1;	q.push(v);	}
}
}		for(i = 1; i <= N; i++)	{	s.insert(make_pair(dist[i], i)); //for sorted distance	}		cout << "BFS results:" << endl;		//prints BFS results and checks if the graph is connected	while(!s.empty())	{	current = *s.begin(); 	s.erase(s.begin());
i = current.second; 	j = current.first;
if(j == INF) //if any infinite value, graph is not connected	{	cout << i << " INF" << endl;	isConnected = false;	}	else	{	cout << i << " " << j << endl;	}
}
//marks blocks of memory as visited	memset(visited, 0, sizeof visited);}

void dfsSearch(int s){	visited[s] = 1; //marking it visited	discover[s] = t++; //assigning and incrementing time
int i, v;
if(!visited[v]) //if vertex is not visited then visit, else continue	{	dfsSearch(v);	}
}
st.push(s); //pushed onto stack for TopSort if it was called	finish[s] = t++; //out time}
void DFS(){
for(i = 1; i <= N; i++)	{	if(visited[i]) //if visited continue, else visit it with DFS	{	continue;	}
dfsSearch(i); //embedded function to actually perform DFS	}
for(i=1;i<=N;i++)	{	s.insert(make_pair(discover[i], i)); //minheap for sorted discovery time	}		cout << "DFS results:" << endl;
while(!s.empty()) //Prints DFS results as long as the multiset is not empty	{	current = *s.begin(); //duplicates the pointer to first object in the multiset	s.erase(s.begin()); //erases the first object in multiset
i = current.second;	cout << i << " " << discover[i] << " " << finish[i] << endl; //prints discover times and finish times	}
}
void TopSort(){	//call DFS so we can have a sorted stack to print	for(i=1;i<=N;i++)	{	if(visited[i])	{	continue;	}
dfsSearch(i);	}
cout<<"Topological Sort results:"<<endl;
//print sorted results from DFS	while(!st.empty())	{	i = st.top(); 	st.pop();
cout << i << endl;	}
//declare blocks of memory as visited	memset(visited, 0, sizeof visited);
}

int main(){	string str, num, input;	int selection, connectedChoice = 0;

//get to input any file, more freedom than declaring file in command line	cout << "Enter the exact name of your input file [case sensitive]: ";	cin >> input;		ifstream inputFile(input); //Read the input file
//checks if the ifstream cannot open	if(inputFile.fail())	{	cout << endl << "No input files matching that name. Terminating..." << endl;	return 0;	}
//Read until the end of file	while(!inputFile.eof())	{	getline(inputFile, str); //read the current line
if(str == "")	{	continue;	}
if(!isdigit(str[0])) //checks to see if the first item in a line is a digit or not	{	cout << "Invalid file format. You have a line beginning with a non-digit. Terminating..." << endl;	return 0;	}
stringstream ss;	ss << str; //convert the line to stream of strings		ss >> num; //read the line num	stringstream(num) >> u;		while(!ss.eof())	{	ss>>num;	if(stringstream(num) >> v)	{	adj[u].push_back(v); //read the adjacent vertices	}	}
N++; //calculate the number of vertices	sort(adj[u].begin(), adj[u].end()); //sort the adjacency list in case it is not sorted	}		//creates arbitrary values for distance, will check later if INF remain	for(i = 1; i <= N; i++)	{	dist[i] = INF;	}
cout << endl << "Valid Input file loaded!" << endl;
while(selection != 4)	{	cout << "************************************************" << endl;	cout << "What type of analysis would you like to perform?" << endl;	cout << "1: Breadth-First Search" << endl;	cout << "2: Depth-First Search" << endl;	cout << "3: Topological Sort" << endl;	cout << "4: Quit" << endl;	cout << "************************************************" << endl;		//read user input and execute selection	cin >> selection;
switch(selection)	{	case 1:	cout << endl;	BFS();	cout << endl;	cout << "Would you like to know if the graph is connected?" << endl;	cout << "1: Yes" << endl;	cout << "Any other key: No" << endl;	cin >> connectedChoice;
switch(connectedChoice)	{	case 1:	if(!isConnected)	{	cout << "The graph is not connected." << endl << endl;	}	else	{	cout << "The graph is connected!" << endl << endl;	}	break;	default:	break;	}	break;	case 2:	cout << endl;	DFS();	cout << endl;	break;	case 3:	cout << endl;	TopSort();	cout << endl;	break;	case 4:	return 0;	default:	cout << endl << "Invalid selection." << endl; //loops the selection prompt until a valid selection is input.	}
}	}
#include<iostream>using namespace std;
const int rows = 8;const int cols = 8;char chessboard[rows][cols];
void setBoard(char chessboard[][cols]);void printBoard(char chessboard[][cols]);
void setBoard(char chessboard[][cols]) {    for(int i = 0; i < rows; i++) {        for(int j = 0; j < cols; j++) {            if(i % 2 == 0 && j % 2 == 0) {                chessboard[i][j] = 'x';            } else {                if(i % 2 != 0 && j % 2 == 1) {                    chessboard[i][j] = 'x';                } else {                    chessboard[i][j] = '-';                }            }        }    }    return;}
void printBoard(char chessboard[][cols]) {    for(int i = 0; i < rows; i++) {        for(int j = 0; j < cols; j++) {            cout << chessboard[i][j] << " ";        }        cout << endl;    }    return;}
int main(int argc, char const *argv[]){    setBoard(chessboard);    printBoard(chessboard);    return 0;}
/*Algorithm:Step 1: Get radius of the cylinder from the user and store in variable rStep 2: Get height of the cylinder from the user and store in variable hStep 3: Multiply radius * radius * height * pi and store in vStep 4: Display the volume*/
#include <iostream>using namespace std;

int main(){        float r; //define variable for radius        float h; //define variable for height        float v;        float pi;        pi=3.1416;
cout<<"Enter height:";        cin>>h;
v=r*r*h*pi;  //compute volume
cout<<"\n************************\n";
cout<<"Volume:"<<v<<endl;//display volume
return 0;}
#include<iostream>#include<fstream>#include<vector>#include<stdio.h> #include<time.h>#include<stdlib.h>using namespace std;
//data storage for parking lot info, admin, managers, users, and ticketsstruct Parking_Lot_info{	int total_Space;	int regular;	int motorcycle;	int disability;};struct Admin{	string name;	string id;	string password;};struct Manager{	string name;	string id;	string password;}; struct User{	string id;	string name;	string password;	string makeModel1;	string makeModel2;	string year;	string plate;};struct Ticket{	string ticket_Number;	string ticket_Amount;	string ticket_Issued;	string ticket_Status;	string reason; 	string plate;};

void Initial_Manager_Vector(char management_People_File_Name[]){	ifstream in;	Manager m;	in.open(management_People_File_Name);	while(getline(in,m.name,',')){		getline(in,m.id,',');		getline(in,m.password);		manager_Vector.push_back(m);	}	in.close();}void Initial_User_Vector(char user_People_File_Name[]){	ifstream in;	User u;	in.open(user_People_File_Name);	while(getline(in,u.name,',')){		getline(in,u.id,',');		getline(in,u.password,',');		getline(in,u.makeModel1,',');		getline(in,u.makeModel2,',');		getline(in,u.year,',');		getline(in,u.plate);		user_Vector.push_back(u);	}	in.close();}void Initial_Ticket_Vector(){	ifstream in;	Ticket t;	in.open("ticket.csv");	while(getline(in,t.ticket_Number,',')){		getline(in,t.ticket_Amount,',');		getline(in,t.ticket_Issued,',');		getline(in,t.ticket_Status,',');		getline(in,t.reason,',');		getline(in,t.plate);		ticket_Vector.push_back(t);	}	in.close();}

void Admin_Menu(){	int Admin_Option;	bool flag = true;	do{		cout << "Select the following option for a particular task." << endl;		cout << "Select 1 to add new administrative employee." << endl;		cout << "Select 2 to remove an administrative employee." << endl;		cout << "Select 3 to view all administrative employee information." << endl;		cout << "Select 4 to search information of a specific administrative employee." << endl;		cout << "Select 5 to change password." << endl;		cout << "Select 6 to add new management employee." << endl;		cout << "Select 7 to remove a management employee." << endl;		cout << "Select 8 to view all management employee information." << endl;		cout << "Select 9 to search information of a specific management employee." << endl;		cout << "Select 10 to remove an user." << endl;		cout << "Select 11 to view all user information." << endl;		cout << "Select 12 to search information of a specific user." << endl;		cout << "Select 15 to Log out." << endl;		cout << "Option: ";		cin >> Admin_Option;		switch(Admin_Option){   //switch to manage the option selection			case 1:				Add_Admin();				break;			case 2:				Remove_Admin();				break;			case 3:				Display_All_Admin();				break;			case 4:				Search_Admin();				break;			case 5:				Change_Password_Admin();				break;			case 6:				Add_Manager();				break;			case 7:				Remove_Manager();				break;			case 8:				Display_All_Manager();				break;			case 9:				Search_Manager();				break;			case 10:				Remove_User();				break;			case 11:				Display_All_User();				break;			case 12:				Search_User();				break; 			case 15:				flag = false;				cout << endl;				Login_System();				break;		}	}while(flag);}void Management_Menu(){	int Manager_Option;	bool flag = true;	do{		cout << "Select the following option for a particular task." << endl;		cout << "Select 1 to remove an user." << endl;		cout << "Select 2 to view all user information." << endl;		cout << "Select 3 to search information of a specific user." << endl;		cout << "Select 4 to issue a ticket." << endl;		cout << "Select 5 to view all the ticket information." << endl;		cout << "Select 6 to view a specific ticket information in details." << endl;		cout << "Select 7 to remove a specific ticket information." << endl;		cout << "Select 8 to change password." << endl;		cout << "Select 9 to Log out." << endl;		cout << "Option: ";		cin >> Manager_Option;		switch(Manager_Option){ //ditto			case 1:				Remove_User();				break;			case 2:				Display_All_User();				break;			case 3:				Search_User();				break;			case 4:				Add_Ticket();				break;			case 5:				Display_All_Ticket();				break;			case 6:				Search_Ticket();				break;			case 7:				Remove_Ticket();				break;			case 8:				Change_Password_Manager();				break;			case 9:				flag = false;				cout << endl;				Login_System();				break;		}	}while(flag);}void User_Menu(){	int User_Option;	bool flag = true;	do{		cout << "Select the following option for a particular task." << endl;		cout << "Select 1 to change password." << endl;		cout << "Select 2 to change vehicle information." << endl;		cout << "Select 3 to view vehicle information." << endl;		cout << "Select 4 to view all ticket information." << endl;		cout << "Select 5 to pay a ticket amount." << endl;		cout << "Select 8 to Log out." << endl;		cout << "Option: ";		cin >> User_Option;		switch(User_Option){			case 1:				Change_Password_User();				break;			case 2:				Change_Vehicle_Info();				break;			case 3:				Display_All_Vehicle();				break;			case 4:				User_Display_Ticket();				break;			case 5:				Pay_Ticket();				break;			case 8:				flag = false;				cout << endl;				Login_System();				break;			}	}while(flag);}void Add_Admin(){	string add_name;	string add_id;	string add_password;	Admin a;	srand((unsigned)time(NULL));	bool flag = true;	char temp1[100];	int temp2;			cout << "Enter administrative employee name: ";	cin.ignore();	getline(cin,add_name);	cout << "Auto generated id for this administrative employee account is: ";	do{		temp2 = rand()%400 + 101;		sprintf(temp1, "%d", temp2);		add_id = temp1;		for(admin_it = admin_Vector.begin(); admin_it != admin_Vector.end(); admin_it++){			if(add_id == admin_it->id){				break;			}		}		if(admin_it == admin_Vector.end()){			flag = false;		}	}while(flag);	cout << add_id << endl;	cout << "Set a password for this administrative employee account: ";	getline(cin,add_password);	cout << "administrative employee entry is complete." << endl << endl;		a.name = add_name;	a.id = add_id;	a.password = add_password;	admin_Vector.push_back(a); }void Remove_Admin(){	bool flag = true;	string remove_id;	cout << "Enter the administrative employee's Id: ";	cin >> remove_id;	for(admin_it = admin_Vector.begin(); admin_it != admin_Vector.end(); admin_it++){		if(admin_it->id == remove_id){			admin_Vector.erase(admin_it);			cout << "Administrative employee is removed." <<endl <<endl;			flag = false;			break;		}	}	if(flag){		cout << "Fail to remove the administrative employee's information!" << endl <<endl;	}}void Display_All_Admin(){	cout << "All Administrative Employee Information" << endl;	cout << "---------------------------------------" << endl;	cout << "             Name                ID" << endl;	cout << "-----------------------------------" << endl;	for(admin_it = admin_Vector.begin(); admin_it != admin_Vector.end(); admin_it++){		cout << admin_it->name << "\t" << "\t" << "\t";		cout << admin_it->id << endl;	}	cout <<endl << endl;}void Search_Admin(){	bool flag = true;	string search_id;	cout << "Enter the administrative employee's id: ";	cin >> search_id;	cout << "             Name                ID" << endl;	cout << "-----------------------------------" << endl;			for(admin_it = admin_Vector.begin(); admin_it != admin_Vector.end(); admin_it++){		if(admin_it->id == search_id){			cout << admin_it->name << "\t" << "\t" << "\t";			cout << admin_it->id << endl << endl;			flag = false;			break;		}	}	if(flag){		cout << "Can't find this administrative employee's information!" << endl << endl;	}	cout <<endl << endl;}void Change_Password_Admin(){	string new_password;	cout << "Enter a new password: ";	cin >> new_password;	admin_it->password = new_password;	cout << "You have changed your password successfully!" <<endl;	cout << endl;}void Add_Manager(){	string add_name;	string add_id;	string add_password;	Manager m;	srand((unsigned)time(NULL));	bool flag = true;	char temp1[100];	int temp2;			cout << "Enter management employee name: ";	cin.ignore();	getline(cin,add_name);	cout << "Auto generated id for this management employee account is: ";	do{		temp2 = rand()%500 + 501;		sprintf(temp1, "%d", temp2);		//itoa(temp2,temp1,10);		add_id = temp1;		for(manager_it = manager_Vector.begin(); manager_it != manager_Vector.end(); manager_it++){			if(add_id == manager_it->id){				break;			}		}		if(manager_it == manager_Vector.end()){			flag = false;		}	}while(flag);	cout << add_id << endl;	cout << "Set a password for this management employee account: ";	getline(cin,add_password);	cout << "Management employee entry is complete." << endl << endl;		m.name = add_name;	m.id = add_id;	m.password = add_password;	manager_Vector.push_back(m); }void Remove_Manager(){	bool flag = true;	string remove_id;	cout << "Enter the management employee's id: ";	cin >> remove_id;	for(manager_it = manager_Vector.begin(); manager_it != manager_Vector.end(); manager_it++){		if(manager_it->id == remove_id){			manager_Vector.erase(manager_it);			cout << "Management employee is removed." <<endl <<endl;			flag = false;			break;		}	}	if(flag){		cout << "Fail to remove the management employee's information!" << endl <<endl;	}}void Display_All_Manager(){	cout << "------All Employee Information-----" << endl;	cout << "-----------------------------------" << endl;	cout << "             Name                ID" << endl;	cout << "-----------------------------------" << endl;	for(manager_it = manager_Vector.begin(); manager_it != manager_Vector.end(); manager_it++){		cout << manager_it->name << "\t" << "\t" << "\t";		cout << manager_it->id << endl;	}	cout <<endl << endl;}void Search_Manager(){	bool flag = true;	string search_id;	cout << "Enter the management employee's id: ";	cin >> search_id;	cout << "             Name                ID" << endl;	cout << "-----------------------------------" << endl;			for(manager_it = manager_Vector.begin(); manager_it != manager_Vector.end(); manager_it++){		if(manager_it->id == search_id){			cout << manager_it->name << "\t" << "\t" << "\t";			cout << manager_it->id << endl << endl;			flag = false;			break;		}	}	if(flag){		cout << "Can't find this management employee's information!" << endl << endl;	}	cout << endl << endl;}void Add_User(){	string add_name;	string add_id;	string add_password;	string add_makeModel1;	string add_makeModel2;	string add_year;	string add_plate;	User u;	bool flag = true;		cout << "Enter name: ";	cin.ignore();	getline(cin,add_name);	do{		cout << "Enter id: ";			//cin.ignore();		getline(cin,add_id);		for(user_it = user_Vector.begin(); user_it != user_Vector.end(); user_it++){			if(add_id == user_it->id){				cout << "This id is already in use! Please Enter again!" << endl;				break;			}		}		if(user_it == user_Vector.end()){			flag = false;		}	}while(flag); 	cout << "Enter password: ";	//cin.ignore();	getline(cin,add_password);	cout << "Now enter your vehicle information..." << endl;	cout << "Enter vehicle make: ";	//cin.ignore();	getline(cin,add_makeModel1);	cout << "Enter vehicle model: ";	//cin.ignore();	getline(cin,add_makeModel2);	cout << "Enter vehicle year: ";	//cin.ignore();	getline(cin,add_year);	cout << "Enter vehicle plate number: ";	//cin.ignore();	getline(cin,add_plate);	cout << "Registration is complete" << endl << endl;		u.name = add_name;	u.id = add_id;	u.password = add_password;	u.makeModel1 = add_makeModel1;	u.makeModel2 = add_makeModel2;	u.year = add_year;	u.plate = add_plate;	user_Vector.push_back(u); 	}void Remove_User(){	bool flag = true;	string remove_id;	cout << "Enter the user's id: ";	cin >> remove_id;	for(user_it = user_Vector.begin(); user_it != user_Vector.end(); user_it++){		if(user_it->id == remove_id){			user_Vector.erase(user_it);			cout << "User is removed." <<endl <<endl;			flag = false;			break;		}	}	if(flag){		cout << "Fail to remove the user's information!" << endl <<endl;	}}void Display_All_User(){	cout << "-----------------------------------------------------All User Information-------------------------------------------------------" << endl;	cout << "--------------------------------------------------------------------------------------------------------------------------------" << endl;	cout << "	Name                          ID               Make               Model                 Year           Plate Number" << endl;	cout << "--------------------------------------------------------------------------------------------------------------------------------" << endl;	for(user_it = user_Vector.begin(); user_it != user_Vector.end(); user_it++){		cout << user_it->name << "\t" << "\t" << "\t";		cout << user_it->id << "\t" << "\t";		cout << user_it->makeModel1 << "\t"<< "\t";		cout << user_it->makeModel2 << "\t" << "\t"<< "\t";		cout << user_it->year << "\t" << "\t";		cout << user_it->plate << endl;	}	cout <<endl << endl;}void Search_User(){	bool flag = true;	string search_id;	cout << "Enter the user's id: ";	cin >> search_id;	cout << "	Name                          ID               Make               Model                 Year           Plate Number" << endl;	cout << "--------------------------------------------------------------------------------------------------------------------------------" << endl;			for(user_it = user_Vector.begin(); user_it != user_Vector.end(); user_it++){		if(user_it->id == search_id){			cout << user_it->name << "\t" << "\t" << "\t";			cout << user_it->id << "\t" << "\t";			cout << user_it->makeModel1 << "\t"<< "\t";			cout << user_it->makeModel2 << "\t" << "\t"<< "\t";			cout << user_it->year << "\t" << "\t";			cout << user_it->plate << endl;			flag = false;			break;		}	}	if(flag){		cout << "Can't find this user's information!" << endl << endl;	}	cout << endl << endl;}void Change_Password_User(){	string new_password;	cout << "Enter a new password: ";	cin >> new_password;	user_it->password = new_password;	cout << "You have changed your password successfully!" <<endl;	cout << endl;}void Change_Vehicle_Info(){	string new_MakeModel1;	string new_MakeModel2;	string new_Year;	string new_Plate;	cout << "Enter the new vehicle make: ";	cin.ignore();	getline(cin,new_MakeModel1);	cout << "Enter the new vehicle model: ";	//cin.ignore();	getline(cin,new_MakeModel2);	cout << "Enter the new vehicle year: ";	//cin.ignore();	getline(cin,new_Year);	cout << "Enter the new vehicle plate number: ";	//cin.ignore();	getline(cin,new_Plate);	user_it->makeModel1 = new_MakeModel1;	user_it->makeModel2 = new_MakeModel2;	user_it->year = new_Year;	user_it->plate = new_Plate;	cout << "You have changed your vehicle information successfully!" <<endl << endl;}void Display_All_Vehicle(){	cout << endl;	cout << "Vehicle make: " << user_it->makeModel1 << endl;	cout << "Vehicle model: " << user_it->makeModel2 << endl;	cout << "Vehicle year: " << user_it->year << endl;	cout << "Vehicle plate number: " << user_it->plate << endl << endl;}void Add_Ticket(){	string add_ticket_number;	string add_ticket_amount;	string add_Reason;	string add_plate;	Ticket t;	srand((unsigned)time(NULL));	bool flag = true;	char temp1[100];	int temp2;		string ticketIssued;	string ticketStat;		cout << "Auto generated ticket number is: ";	do{		temp2 = rand()%49000 + 1001;		sprintf(temp1, "%d", temp2);		//itoa(temp2,temp1,10);		add_ticket_number = temp1;		for(ticket_it = ticket_Vector.begin(); ticket_it != ticket_Vector.end(); ticket_it++){			if(add_ticket_number == ticket_it->ticket_Number){				break;			}		}		if(ticket_it == ticket_Vector.end()){			flag = false;		}	}while(flag);	cout << add_ticket_number << endl;	cout << "Enter ticket amount: ";	cin.ignore();	getline(cin,add_ticket_amount);	cout << "Reason of ticket: ";	getline(cin,add_Reason);	cout << "Enter vehicle plate number: ";	getline(cin,add_plate);	cout << "Ticket has been recorded successfully."<<endl<<endl;	ticketIssued = manager_it->id;	ticketStat = "Unpaid";		t.ticket_Number = add_ticket_number;	t.ticket_Amount = add_ticket_amount;	t.ticket_Issued = ticketIssued;	t.ticket_Status = ticketStat;	t.reason = add_Reason;	t.plate = add_plate;	ticket_Vector.push_back(t);}void Display_All_Ticket(){	cout << "Ticket number     Ticket amount     Issued by     Ticket Status     Reason" << endl;	cout << "--------------------------------------------------------------------------" << endl;	for(ticket_it = ticket_Vector.begin(); ticket_it != ticket_Vector.end(); ticket_it++){		cout << "\t" << ticket_it->ticket_Number << "\t" << "\t";		cout << "$" << ticket_it->ticket_Amount << "\t" << "\t"; cout << ticket_it->ticket_Issued << "\t"<< "\t"; cout << ticket_it->ticket_Status << "\t"<< "\t"; cout << ticket_it->reason << endl; } cout <<endl << endl;}void Search_Ticket(){ bool flag = true; string search_number; cout << "Enter the ticket number: "; cin.ignore(); getline(cin,search_number); cout << "Ticket number Ticket amount Issued by Ticket Status Reason" << endl; cout << "--------------------------------------------------------------------------" << endl; for(ticket_it = ticket_Vector.begin(); ticket_it != ticket_Vector.end(); ticket_it++){ if(ticket_it->ticket_Number == search_number){ cout << "\t" << ticket_it->ticket_Number << "\t" << "\t"; cout << "$" << ticket_it->ticket_Amount << "\t" << "\t";			cout << ticket_it->ticket_Issued << "\t"<< "\t";			cout << ticket_it->ticket_Status << "\t"<< "\t";			cout << ticket_it->reason << endl;		}	}	cout <<endl << endl;}void Remove_Ticket(){	bool flag = true;	string remove_number;	cout << "Enter the ticket number: ";	cin.ignore();	getline(cin,remove_number);	for(ticket_it = ticket_Vector.begin(); ticket_it != ticket_Vector.end(); ticket_it++){		if(ticket_it->ticket_Number == remove_number){			ticket_Vector.erase(ticket_it);			cout << endl;			cout << "Ticket is removed." <<endl <<endl;			flag = false;			break;		}	}	if(flag){		cout << "Fail to remove the ticket!" << endl <<endl;	}}void Change_Password_Manager(){	string new_password;	cout << "Enter a new password: ";	cin >> new_password;	manager_it->password = new_password;	cout << "You have changed your password successfully!" <<endl;	cout << endl;}void User_Display_Ticket(){	cout << "Ticket number     Ticket amount     Issued by     Ticket Status     Reason" << endl;	cout << "--------------------------------------------------------------------------" << endl;	for(ticket_it = ticket_Vector.begin(); ticket_it != ticket_Vector.end(); ticket_it++){		if(user_it->plate == ticket_it->plate){			cout << "\t" << ticket_it->ticket_Number << "\t" << "\t";			cout << "$" << ticket_it->ticket_Amount << "\t" << "\t"; cout << ticket_it->ticket_Issued << "\t"<< "\t"; cout << ticket_it->ticket_Status << "\t"<< "\t"; cout << ticket_it->reason << endl; break; } } cout <<endl << endl;}void Pay_Ticket(){ string YorN; cout << "Do you want to pay$" << ticket_it->ticket_Amount << " right now? (Type in Yes or No):";	cin >> YorN;	if(YorN == "Yes" || YorN == "YES" || YorN == "yes"){		for(ticket_it = ticket_Vector.begin(); ticket_it != ticket_Vector.end(); ticket_it++){			if(user_it->plate == ticket_it->plate){				ticket_it->ticket_Amount = "0";				ticket_it->ticket_Status = "Paid";				cout << "The ticket amount is paid off." << endl << endl;				break;			}		}	}	else if(YorN == "No" || YorN == "NO" || YorN == "no"){		cout << endl << endl;	}		}void Store_Admin_Data(char admin_People_File_Name[]){  //Store all the changes to the admin's data in to the file.	ofstream out;	out.open(admin_People_File_Name);	for(admin_it = admin_Vector.begin(); admin_it != admin_Vector.end(); admin_it++){		out << admin_it->name << ",";		out << admin_it->id << ",";		out << admin_it->password << endl;	}	out.close();}void Store_Manager_Data(char management_People_File_Name[]){  //Store all the changes to the manager's data in to the file.	ofstream out;	out.open(management_People_File_Name);	for(manager_it = manager_Vector.begin(); manager_it != manager_Vector.end(); manager_it++){		out << manager_it->name << ",";		out << manager_it->id << ",";		out << manager_it->password << endl;	}	out.close();}void Store_User_Data(char user_People_File_Name[]){  //Store all the changes to the user's data in to the file.	ofstream out;	out.open(user_People_File_Name);	for(user_it = user_Vector.begin(); user_it != user_Vector.end(); user_it++){		out << user_it->name << ",";		out << user_it->id << ",";		out << user_it->password << ",";		out << user_it->makeModel1 << ",";		out << user_it->makeModel2 << ",";		out << user_it->year << ",";		out << user_it->plate << endl;	}	out.close();}void Store_Ticket_Data(){  //Store all the changes to the ticket's data in to the file.	ofstream out;	out.open("ticket.csv");	for(ticket_it = ticket_Vector.begin(); ticket_it != ticket_Vector.end(); ticket_it++){		out << ticket_it->ticket_Number << ",";		out << ticket_it->ticket_Amount << ",";		out << ticket_it->ticket_Issued << ",";		out << ticket_it->ticket_Status << ",";		out << ticket_it->reason << ",";		out << ticket_it->plate << endl;	}	out.close();}
int main(){        //char array to store the user input for the file search	char input_File_Name[100]; 	char admin_People_File_Name[100];	char management_People_File_Name[100];	char user_People_File_Name[100];		ifstream in; 	Parking_Lot_info *pli; //Structure pointer	int pln; //Parking lot number	int max_Space = 8; // Max number of parking space in a row	int t = 0; //Determine when it needs to switch to the next row		//relevant strings for admin, management, and users	string admin_Name, admin_Id, admin_Password;	string management_Name, management_Id, management_Password;	string user_Name, user_Id, user_Password;		string user_Make_Model1, user_Make_Model2, user_Year, user_Plate_Number;
//get filename	cout << "Enter file name: "; 	cin.getline(input_File_Name,100);	in.open(input_File_Name);	if(!in){		cout << "Can't open the file!" << endl; //error check		return 0;	}
in >> pln;	pli = new Parking_Lot_info[pln];		//read data in for parking lot	for(int i=0; i<pln; i++){		in >> pli[i].regular;		in >> pli[i].motorcycle;		in >> pli[i].disability;		pli[i].total_Space = pli[i].regular + pli[i].motorcycle + pli[i].disability;		//display the initial read in data for parking lot		cout << "Parking lot number: " << i+1 << endl;		cout << "Number of parking space: " << pli[i].total_Space << endl;		cout << "Number of regular parking space: " << pli[i].regular << endl;		cout << "Number of motorcycle parking space: " << pli[i].motorcycle << endl;		cout << "Number of disability parking space: " << pli[i].disability << endl;					cout << "Parking space layout is shown below." << endl;		cout << "---------------------------------" << endl;		cout << "|";		t = 0; //Reset t to 0;		for(int j=0; j <pli[i].motorcycle; j++){			t++;			cout << " M " << "|";			if(t%max_Space == 0){				cout << endl;				cout << "---------------------------------" << endl;			}		}		for(int k=0; k <pli[i].disability; k++){			t++;				cout << " D " << "|";					if(t%max_Space == 0){				cout << endl;				cout << "---------------------------------" << endl;			}		}			for(int l=0; l <pli[i].regular; l++){			t++;				cout << " R " << "|";					if(t%max_Space == 0){				cout << endl;				cout << "---------------------------------" << endl;			}		}		cout << endl;		cout << "---------------------------------" << endl;		cout << endl;	} 		    //read in admin, management, and user data	in >> admin_People_File_Name;	in >> management_People_File_Name;	in >> user_People_File_Name;	in.close();		//display initial administrative employee info	in.open(admin_People_File_Name);	cout << "All Administrative Employee Information" << endl;	cout << "---------------------------------------" << endl;	cout << "             Name                ID" << endl;	cout << "-----------------------------------" << endl;	while(getline(in,admin_Name,',')){		cout << admin_Name << "\t" << "\t" << "\t";		getline(in,admin_Id,',');		cout << admin_Id << endl;		getline(in,admin_Password);	}	cout << endl;	in.close();	//display all employee information	in.open(management_People_File_Name);	cout << "------All Employee Information-----" << endl;	cout << "-----------------------------------" << endl;	cout << "             Name                ID" << endl;	cout << "-----------------------------------" << endl;	while(getline(in,management_Name,',')){		cout << management_Name << "\t" << "\t" << "\t";		getline(in,management_Id,',');		cout << management_Id << endl;		getline(in,management_Password);	}	cout << endl;	in.close();		//display all user information	in.open(user_People_File_Name);	cout << "-----------------------------------------------------All User Information-------------------------------------------------------" << endl;	cout << "--------------------------------------------------------------------------------------------------------------------------------" << endl;	cout << "	Name                          ID               Make               Model                 Year           Plate Number" << endl;	cout << "--------------------------------------------------------------------------------------------------------------------------------" << endl;	while(getline(in,user_Name,',')){		cout << user_Name << "\t" << "\t" << "\t";		getline(in,user_Id,',');		cout << user_Id << "\t" << "\t";		getline(in,user_Password,',');		getline(in,user_Make_Model1,',');		cout << user_Make_Model1 << "\t"<< "\t";		getline(in,user_Make_Model2,',');		cout << user_Make_Model2 << "\t" << "\t"<< "\t";		getline(in,user_Year,',');		cout << user_Year << "\t" << "\t";		getline(in,user_Plate_Number);		cout << user_Plate_Number << endl;	}	cout << endl;	in.close();			Initial_Admin_Vector(admin_People_File_Name);	Initial_Manager_Vector(management_People_File_Name);	Initial_User_Vector(user_People_File_Name);	Initial_Ticket_Vector();	Login_System();		//store NEW admin, manager, user, and ticket data	Store_Admin_Data(admin_People_File_Name);	Store_Manager_Data(management_People_File_Name);	Store_User_Data(user_People_File_Name);	Store_Ticket_Data();		return 0;}
//Leif Messinger//Finds all sets of 5 5 letter words that don't have duplicate letters in either themselves or each other.//First it reads the words in and puts them in groups of their bitmasks//After that, we recurse on each group. Before doing that, we remove the group from the set of other groups to check it against.#include <cstdio> //getchar, printf#include <cassert> //assert#include <vector>#include <set>#include <algorithm> //std::copy_if#include <iterator> //std::back_inserter
#define CHECK_FOR_CRLF true#define MIN_WORDS 5#define MAX_WORDS 5#define WORD_TOO_LONG(len) (len != 5)
const unsigned int charToBitmask(const char bruh){	assert(bruh >= 'a' && bruh <= 'z');	return (1 << (bruh - 'a'));}
unsigned int bitmask = 0;	unsigned int wordLength = 0;	bool duplicateLetters = false;	for(char c = getchar(); c >= 0; c = getchar()){		if(CHECK_FOR_CRLF && c == '\r'){			continue;		}		if(c == '\n'){			if(!(WORD_TOO_LONG(wordLength) || duplicateLetters)) bitmasks.insert(bitmask);			bitmask = 0;			wordLength = 0;			duplicateLetters = false;			continue;		}		if((bitmask & charToBitmask(c)) != 0) duplicateLetters = true;		bitmask |= charToBitmask(c);		++wordLength;	}
//Just to be clear, when I mean "word", I mean a group of words with the same letters.void recurse(std::vector<unsigned int>& oldBitmasks, std::vector<unsigned int> history, const unsigned int currentBitmask){	//If there's not enough words left	if(oldBitmasks.size() + (-(history.size())) + (-MIN_WORDS) <= 0){		//If there's enough words		if(history.size() >= MIN_WORDS){			//Print the list			printBitmasks(history);		}		return;	//To make it faster, we can stop it after 5 words too	}else if(history.size() >= MAX_WORDS){		//Print the list		printBitmasks(history);		return;	}
while(newBitmasks.size() > 0){		//I know this modifies 'oldBitmasks' too. It's intentional.		//This makes it so that the word is never involved in any of the child serches or any of the later searches in this while loop.		const unsigned int word = newBitmasks.back(); newBitmasks.pop_back();
std::vector<unsigned int> newHistory = history;		newHistory.push_back(word);
return 0;}
//From https://create.arduino.cc/projecthub/abhilashpatel121/easyfft-fast-fourier-transform-fft-for-arduino-9d2677#include <cmath>#include <iostream>const unsigned char sine_data[] = {	//Quarter a sine wave	0, 	4, 9, 13, 18, 22, 27, 31, 35, 40, 44, 	49, 53, 57, 62, 66, 70, 75, 79, 83, 87, 	91, 96, 100, 104, 108, 112, 116, 120, 124, 127, 	131, 135, 139, 143, 146, 150, 153, 157, 160, 164, 	167, 171, 174, 177, 180, 183, 186, 189, 192, 195, //Paste this at top of program	198, 201, 204, 206, 209, 211, 214, 216, 219, 221, 	223, 225, 227, 229, 231, 233, 235, 236, 238, 240, 	241, 243, 244, 245, 246, 247, 248, 249, 250, 251, 	252, 253, 253, 254, 254, 254, 255, 255, 255, 255};float sine(int i){	//Inefficient sine	int j=i;	float out;	while(j < 0) j = j + 360;	while(j > 360) j = j - 360;	if(j > -1 && j < 91) out = sine_data[j];	else if(j > 90 && j < 181) out = sine_data[180 - j];	else if(j > 180 && j < 271) out = -sine_data[j - 180];	else if(j > 270 && j < 361) out = -sine_data[360 - j];	return (out / 255);}
float cosine(int i){	//Inefficient cosine	int j = i;	float out;	while(j < 0) j = j + 360;	while(j > 360) j = j - 360;	if(j > -1 && j < 91) out = sine_data[90 - j];	else if(j > 90 && j < 181) out = -sine_data[j - 90];	else if(j > 180 && j < 271) out = -sine_data[270 - j];	else if(j > 270 && j < 361) out = sine_data[j - 270];	return (out / 255);}
//Example data:
//-----------------------------FFT Function----------------------------------------------//float* FFT(int in[],unsigned int N,float Frequency){	//Result is highest frequencies in order of loudness. Needs to be deleted.	/*	Code to perform FFT on arduino,	setup:	paste sine_data [91] at top of program [global variable], paste FFT function at end of program	Term:	1. in[] : Data array, 	2. N : Number of sample (recommended sample size 2,4,8,16,32,64,128...)	3. Frequency: sampling frequency required as input (Hz)
If sample size is not in power of 2 it will be clipped to lower side of number. 	i.e, for 150 number of samples, code will consider first 128 sample, remaining sample will be omitted.	For Arduino nano, FFT of more than 128 sample not possible due to mamory limitation (64 recomended)	For higher Number of sample may arise Mamory related issue,	Code by ABHILASH	Contact: [email protected] 	Documentation:https://www.instructables.com/member/abhilash_patel/instructables/	2/3/2021: change data type of N from float to int for >=256 samples	*/
unsigned int sampleRates[13]={1,2,4,8,16,32,64,128,256,512,1024,2048};	int a = N;	int o;	for(int i=0;i<12;i++){		//Snapping N to a sample rate in sampleRates		if(sampleRates[i]<=a){			o = i;		}	}		 	int in_ps[sampleRates[o]] = {}; //input for sequencing	float out_r[sampleRates[o]] = {}; //real part of transform	float out_im[sampleRates[o]] = {}; //imaginory part of transform	int x = 0; 	int c1;	int f;	for(int b=0;b<o;b++){ // bit reversal		c1 = sampleRates[b];		f = sampleRates[o] / (c1 + c1);		for(int j = 0;j < c1;j++){ 			x = x + 1;			in_ps[x]=in_ps[j]+f;		}	}
for(int i=0;i<sampleRates[o];i++){ // update input array as per bit reverse order		if(in_ps[i]<a){			out_r[i]=in[in_ps[i]];		}		if(in_ps[i]>a){			out_r[i]=in[in_ps[i]-a];		} 	}

int i10,i11,n1;	float e,c,s,tr,ti;
for(int i=0;i<o;i++){ //fft		i10 = sampleRates[i]; // overall values of sine/cosine :		i11 = sampleRates[o] / sampleRates[i+1]; // loop with similar sine cosine:		e = 360 / sampleRates[i+1];		e = 0 - e;		n1 = 0;
for(int j=0;j<i10;j++){			c=cosine(e*j);			s=sine(e*j); 			n1=j;
for(int k=0;k<i11;k++){				tr = c*out_r[i10 + n1]-s*out_im[i10 + n1];				ti = s*out_r[i10 + n1]+c*out_im[i10 + n1];
out_r[n1 + i10] = out_r[n1]-tr;				out_r[n1] = out_r[n1]+tr;
out_im[n1 + i10] = out_im[n1]-ti;				out_im[n1] = out_im[n1]+ti;
n1 = n1+i10+i10;			} 		}	}
/*	for(int i=0;i<sampleRates[o];i++)	{	std::cout << (out_r[i]);	std::cout << ("\t"); // un comment to print RAW o/p 	std::cout << (out_im[i]); std::cout << ("i"); 	std::cout << std::endl;	}	*/

//---> here onward out_r contains amplitude and our_in conntains frequency (Hz)	for(int i=0;i<sampleRates[o-1];i++){ // getting amplitude from compex number		out_r[i] = sqrt(out_r[i]*out_r[i]+out_im[i]*out_im[i]); // to increase the speed delete sqrt		out_im[i] = i * Frequency / N;		std::cout << (out_im[i]); std::cout << ("Hz");		std::cout << ("\t");	// un comment to print freuency bin 		std::cout << (out_r[i]);		std::cout << std::endl;	}

x = 0; // peak detection	for(int i=1;i<sampleRates[o-1]-1;i++){		if(out_r[i]>out_r[i-1] && out_r[i]>out_r[i+1]){			in_ps[x] = i; //in_ps array used for storage of peak number			x = x + 1;		} 	}

s = 0;	c = 0;	for(int i=0;i<x;i++){ // re arraange as per magnitude		for(int j=c;j<x;j++){			if(out_r[in_ps[i]]<out_r[in_ps[j]]){				s=in_ps[i];				in_ps[i]=in_ps[j];				in_ps[j]=s;			}		}		c=c+1;	}	float* f_peaks = new float[sampleRates[o]];	for(int i=0;i<5;i++){ // updating f_peak array (global variable)with descending order		f_peaks[i]=out_im[in_ps[i]];	}	return f_peaks;}
//------------------------------------------------------------------------------------////main.cppint data[64]={14, 30, 35, 34, 34, 40, 46, 45, 30, 4, -26, -48, -55, -49, -37,-28, -24, -22, -13, 6, 32, 55, 65, 57, 38, 17, 1, -6, -11, -19, -34, -51, -61, -56, -35, -7, 18, 32, 35, 34, 35, 41, 46, 43, 26, -2, -31, -50,-55, -47, -35, -27, -24, -21, -10, 11, 37, 58, 64, 55, 34, 13, -1, -7};
int main(){	const unsigned int SAMPLE_RATE = 48*1000;	//48khz	auto result = FFT(data,64,SAMPLE_RATE);	std::cout << result[0] << " " << result[1] << " " << result[2] << " " << result[3] << std::endl;	delete[] result;	return 0;}