몇 가지 도움이 필요합니다. 배열에 파일을 읽었습니다. 배열을 가져 와서 숫자가 포맷되도록 포맷해야합니다. 텍스트 파일은 숫자 목록 일뿐입니다. 예를 들어 처음 두 숫자를 가져 와서 "1-0"과 같이 콘솔에 출력되도록 포맷해야합니다. 지금까지 제 코드가 있습니다. 형식 지정이 수행되어야하는 불완전한 기능을 확인하십시오.배열 및 출력을 포맷하는 방법은 무엇입니까?
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<fstream>
using namespace std;
string ArrayFormat(int array[]);
int main() {
const int ARRAY_SIZE = 21;
string filename;
ifstream inputfile;
int score[ARRAY_SIZE];
cout <<"\nPlease enter the name of a file: ";
cin >> filename;
inputfile.open(filename.c_str());
if (inputfile.fail()){
perror(filename.c_str());
exit(1);
}// end of error test
for (int i=0;i<20;i++){
inputfile >> score[i];
// cout << score[i] << endl;
}// end of for loop to read into array
inputfile.close();
}// end of main
string ArrayFormat(int array[]){
for(int i=0; i<=21; i++){
}
}// end of ArrayFormat
배열에 처음에 어떤 형식이 저장됩니까? 당신이 필요로하는 것이 무엇인지 정확하게 설명하십시오. – DaveyLaser
나머지 숫자는 두 번째 숫자를 넘어 무엇입니까? – dasblinkenlight
처음에는 한 줄에 하나씩 목록으로 저장됩니다. – user1793058