Write a program that lists 30 employees' names, their jobs, and the store where they work using a two-dimensional array.
#include <iostream>
#include "string"
struct Info{
std::string first, second;
Info(){
static bool isWorker = true;
std::cout<<(isWorker?"First and second name: \n ":"Place: \n ");
std::cin>>first;
std::cout<<(isWorker?"":"Job: \n ");
std::cin>>second;
isWorker = !isWorker;
}
~Info() {
static bool isWorker = true;
std::cout<<(isWorker?"First name: ":"Place: ")<<first<<" ";
std::cout<<(isWorker?"Second name: ":"Job: ")<<second<<" ";
std::cout<<(isWorker?"- ":"\n");
isWorker = !isWorker;
}
};
int main() {
Info data[30][2]{};
while(std::cin.fail()){
int x;
std::cout<<"\nNumber of Employer: ";
std::cin>>x;
if(x>30||x<1)
continue;
--x;
std::cout<<"\nFirst name: "<<data[x][0].first<<"\nSecond name: "<<data[x][0].second;
std::cout<<"\nPlace: "<<data[x][1].first<<"\nJob: "<<data[x][1].second;
}
return 0;
}
Comments
Leave a comment