#include #include #include #include #include #include template 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 std::istream& operator>>(std::istream& in, comma_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> istrit; typedef std::ostream_iterator ostrit; std::vector 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 << "平均点:" << std::setprecision(1) << std::fixed << double(vec[0]+vec[1]+vec[2])/3.0 << "\n"; return 0; }