結果
| 問題 |
No.9014 テストの合計点と平均点
|
| ユーザー |
|
| 提出日時 | 2023-07-17 03:13:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,192 bytes |
| コンパイル時間 | 816 ms |
| コンパイル使用メモリ | 78,652 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-17 21:20:43 |
| 合計ジャッジ時間 | 1,389 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 3 |
ソースコード
#include <vector>
#include <iterator>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <iomanip>
template<class T, char sep=','>
struct comma_sep { //type used for temporary input
T t; //where data is temporarily read to
operator const T&() const {return t;} //acts like an int in most cases
};
template<class T, char sep>
std::istream& operator>>(std::istream& in, comma_sep<T,sep>& t)
{
if (!(in >> t.t)) //if we failed to read the int
return in; //return failure state
if (in.peek()==sep) //if next character is a comma
in.ignore(); //extract it from the stream and we're done
else //if the next character is anything else
in.clear(); //clear the EOF state, read was successful
return in; //return
}
int main() {
typedef std::istream_iterator<comma_sep<int>> istrit;
typedef std::ostream_iterator<int> ostrit;
std::vector<int> vec(istrit(std::cin), istrit());
//std::copy(vec.begin(), vec.end(), ostrit(std::cout, ";"));
std::cout << "合計点:" << vec[0]+vec[1]+vec[2] << "\n";
std::cout << "平均点:" << (vec[0]+vec[1]+vec[2])/3 << std::setprecision(1) << "\n";
return 0;
}