Salve, il seguente programma dovrebbe prendere in input il numero di operai in un azienda, successivamente di ogni operaio il chiede nome, anno di nascita e salario. Non capisco perchè purnon essendoci errori di compilazione l'input del nome è come se non ci fosse; ecco il codice:
#include <iostream>
#include <string>
#include <vector>
int main(){
int n;
std::vector<std::string> names;
std::vector<int> y_birth;
std::vector<int> salaries;
std::cout << "how many employees do you want to register?" << std::endl;
std::cin >> n;
for(int i = 0; i < n; i++){
std::string name;
std::cout << "Enter the name of the employee " << i +1 << ":" << std::endl;
getline(std::cin, name);
names.push_back(name);
int year;
std::cout << "Enter the year of birth of " << name << ":" << std::endl;
std::cin >> year;
y_birth.push_back(year);
int salary;
std::cout << "Enter the year salary of " << name << ":" << std::endl;
std::cin >> salary;
salaries.push_back(salary);
}
std::cout << std::endl << "The employees who can retire are:" << std::endl;
for(int i = 0; i < n; i++){
if(y_birth[i] >= 60)
std::cout << names[i] << "\t" << y_birth[i] << "\t" << salaries[i] << std::endl;
}
std::cout << std::endl << "Underage employees are:" << std::endl;
for(int i = 0; i < n; i++){
if(y_birth[i] < 18)
std::cout << names[i] << "\t" << y_birth[i] << "\t" << salaries[i] << std::endl;
}
system("pause");
return 0;
}