ぼるじょあがC/C++の宿題を片づけますYO! 68代目at TECHぼるじょあがC/C++の宿題を片づけますYO! 68代目 - 暇つぶし2ch■コピペモード□スレを通常表示□オプションモード□このスレッドのURL■項目テキスト69: ◆wSaCDPDEl2 07/06/10 00:10:22 問題1,2,33つともやっていただけたんですか。ありがとうございます! ファイルが見つからないというエラーが出たんですが、同じフォルダ内に入れないとダメとかいう制限でもあるのでしょうか? 70:homoじょあ ◆5OLf4yFnuM 07/06/10 00:27:40 (・3・) エェー 新スレおつんつんん C++っぽくだとこんなんかNA? #include <iostream> #include <sstream> #include <fstream> #include <string> using namespace std; #define filename "x-file.txt" int main(){ fstream file; string str; int point = 0; double gpa = 0.0; file.open( filename, ios::in ); while( !file.eof() ){ char buf[256]; getline(file, str); istringstream is( str ); int p; double g; is >> buf >> buf >> p >> g; point += p; gpa += g; } file.close(); file.open( filename, ios::app ); file << point /5 << " " << gpa /5 << endl; file.close(); return 0; } 次ページ最新レス表示レスジャンプ類似スレ一覧スレッドの検索話題のニュースおまかせリストオプションしおりを挟むスレッドに書込スレッドの一覧暇つぶし2ch