//感謝李奕快速支援^^ 想要什麼,許個願就有~oh ya 

#include<iostream>
#include<fstream> //opening file,you should include this!!
#include<string> //for name
#include<iomanip> //for setw and left want more? try cplusplus.com
using namespace std;
int main()
{
ifstream fin("input.txt"); //ifstream is a type for input file, fin is a name like cin
ofstream fout("output.txt");

string name;
int score[5];

fout<<"姓名 國文 數學 社會 自然 英文" <<endl;

while(!fin.eof()) //eof: end of file, the most important function when reading files
{
fin>>name; //use fin like use cin
for(int i=0;i<5;i++)
{
fin>>score[i];
}

fout<<setw(10)<<left<<name; //setw: set width, you can control the space without fout<<" ";
for(int i=0;i<5;i++)
{
fout<<setw(5)<<left<<score[i];
}
fout<<endl; //==fout<<"\n";
}
//system("PAUSE");
}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Iris 的頭像
    Iris

    Iris-女王向前走

    Iris 發表在 痞客邦 留言(0) 人氣()