わかりました、助けが必要です。ファイルを配列に読み込みました。数値がフォーマットされるように、配列を取得してフォーマットする必要があります。テキスト ファイルは単なる数字のリストです。たとえば、最初の 2 つの数値を取得して、「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