을 사용하는 C++ 코드에 붙어 있습니다. 현재 여기에서 어디로 가야할 지 모르겠습니다 ...구조체
플레이어에 대한 데이터를 저장할 구조체를 선언하는 프로그램을 작성해야합니다. 그런 다음 10 명의 야구 선수에 대한 데이터를 저장할 10 개의 구성 요소 배열을 선언합니다.
이 프로그램은 파일에서 읽고 플레이어의 팀, 선수의 이름, 홈런, 타율의 수 등 10 명 야구 선수에 대한 데이터를 저장하고, 실행이 타점.
프로그램 인쇄 아웃 메뉴 (이
- 인쇄 밖으로 모든 사용자와 통계 : 루프에서, 그래서 이것은에 사용자에게 선택권을주는) 다시 다시 수행 할 수 있습니다 특정 t EAM
- 업데이트는 특정 선수에 대한 데이터는 프로그램이 종료하기 전에,
을 (통계 중 하나를 변경) 사용자에게 출력 파일에 데이터를 저장 할 수있는 옵션을 제공합니다. 사람이 나는 매우 감사하게 될 것입니다 어떤 조언 조언이있는 경우
... 난 ... C로 코딩 ++와 여기 갇혀에 비교적 새로운 해요 사전에 감사
#include <iostream>
#include <fstream>
using namespace std;
struct BaseballID
{
string teamName, playerFirstName, playerLastName;
int homeRuns, rbi;
double batting_average;
};
int main()
{
BaseballID listofplayers[10];
ifstream infile;
infile.open("https://stackoverflow.com/users/AlecKleyer/Desktop/computer science term 2/BaseballStats.txt");
if (!infile)
{
cout << "Error opening file!";
return 0;
}
for (int j = 0; j < 10; j++) {
infile >> listofplayers[j].teamName >> listofplayers[j].playerFirstName >> listofplayers[j].playerLastName >>listofplayers[j].homeRuns >> listofplayers[j].rbi >> listofplayers[j].batting_average;
}
cout << "Please Type The Following Letter: ";
cout << "\n(A) For All Users and Stats";
cout << "\n(B) For A Specific Player";
cout << "\n(C) Print out for specific team";
cout << "\n(D) Update stats for a player";
char input = 0;
cin >> input;
if (input == 'A' || input == 'a') {
printInfoAll(*listofplayers[]);
}
if (input == 'B' || input == 'b') {
}
if (input == 'C' || input == 'c') {
}
if (input == 'D' || input == 'd') {
}
}
void printInfoAll(listofplayers1[])
{
for (int i = 0; i < 10; i++) {
cout << &listofplayers[i];
}
}
main()에서와 같이'listofplayers'를 정의하려면'typedef struct {} BaseballID; '와 같은'BaseballID' 구조체를 정의해야합니다. –
Josh
이 종류의 컨텍스트를 배웠습니다. C++ 지식에 대한 나의 천장이 작아서이 실험실은 저에게 어렵습니다. @Josh –
배열을 임의의 크기로 하드 세트하는 대신 벡터 및 push_back을 사용하여 여러 요소를 처리 할 수 있도록하는 것이 좋습니다. –