結果

問題 No.9014 テストの合計点と平均点
ユーザー suj2tosuj2to
提出日時 2023-07-17 03:13:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,192 bytes
コンパイル時間 742 ms
コンパイル使用メモリ 78,152 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 00:16:52
合計ジャッジ時間 1,520 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0