이 프로그램은 10 개의 빈에서 같은 수의 부품을 가진 빈을 선택합니다. 프로그램에서 하나를 선택하면 특정 빈에서 부품을 추가하거나 제거할지 묻습니다. 어떻게 구조 배열에서 요소를 가져올 수 있습니다.
// 구조 구조체 재고 {구조 배열의 요소 얻기
char description[35];
int num;
};
//Function Prototypes.
void choiceMenu(Inventory[], int);
void AddParts(Inventory[], int);
void RemoveParts(Inventory[]);
int main()
{
char election;
int choice;
const int Number_Bins = 10;
Inventory parts[Number_Bins] = {
{"Valve", 10},
{"Bearing", 5},
{"Bushing", 15},
{"Coupling", 21},
{"Flange", 7},
{"Gear", 5},
{"Gear Housing", 5},
{"Vacuum Gripper", 25},
{"Cable", 18},
{"Rod", 12}
};
는 누적으로 일을하려고처럼 9 0에서 배열의 요소를 넣지 않고 그것을 할 수있는 다른 방법이 있습니까. 배열에서 특정 요소를 취하는 방법은 무엇입니까?
void choiceMenu(Inventory bin[], int z)
{
cout << " Inventoy Bins\n";
cout << " = = = = = = = = \n";
cout << " *Choose the part of your preference.\n";
cout << " 1. Valve" << bin[0].num << endl;
cout << " 2. Bearing. Currently Number of Bearing = " << bin[1].num << endl;
cout << " 3. Bushing. Currently Number of Bushing = " << bin[2].num << endl;
cout << " 4. Coupling. Currently Number of Coupling = " << bin[3].num << endl;
cout << " 5. Flange. Currently Number of Flange = " << bin[4].num << endl;
cout << " 6. Gear. Currently Number of Gear = " << bin[5].num << endl;
cout << " 7. Gear_Housing" << bin[6].num << endl;
cout << " 8. Vacuum_Gripper" << bin[7].num << endl;
cout << " 9. Cable. Currently Number of Cable = " << bin[8].num << endl;
cout << " 10. Rod. Currently Number of Rod = " << bin[9].num << endl;
cout << " 11. Choose 11 to quit the Program" << endl;
}
'위해 (; 나는 Number_Bins를
이 모든 빈의 모든 부분의 수를 변경합니다. – user3019164
내가 짐작할 정도로 나는 당신의 질문을 이해하지 못한다. –