#include<iostream>
#include<fstream>
#include<ostream>
#include<iomanip>
using namespace std;
int main() {
int m;
cout << "請輸入學生個數:" << " ";
cin >> m;
ofstream ofile("grade.txt");
ofile<< "Grade" << setw(10) << "Count" << setw(15) << "Histogram" << endl;
cout << "請輸入年紀,評分:" << endl;
for (int i = 0; i < m; i++) {
int x = 0, y = 0;
cin >> x >> y;
int j = 0;
ofile << setiosflags(ios::left)<< setw(10) << x<< resetiosflags(ios::left) << setw(10) << y <<setw(15);
while (j < y) {
ofile << "*";
j++;
}
ofile<< endl;
}
//////這里//////
ofile.close();
cout << "輸出完畢" << endl;
return 0;
}
uj5u.com熱心網友回復:
程式前面不是都有輸出嗎?照著寫就可以了uj5u.com熱心網友回復:
不是,我是要輸出TXT文本里的內容。我除了輸入了資料外還要輸入*
uj5u.com熱心網友回復:
寫入txt之后再讀出來嗎?那要在close之后uj5u.com熱心網友回復:
那我該怎么做呢?謝謝大神賜教
uj5u.com熱心網友回復:
書上找個例子修改一下就好了uj5u.com熱心網友回復:
。。。。。。。。。。。
uj5u.com熱心網友回復:
都是這樣過來的,別老想著走捷徑拿現成的uj5u.com熱心網友回復:
教育的對,大神說的有理。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/20634.html
標籤:基礎類
下一篇:修改新密碼
