Submission #1242421
Source Code Expand
#include <iostream> #include <vector> using namespace std; string calDir(double dir); int toWind(double wind); int calWind(int wind); int main(){ double dir; double wind; cin >> dir >> wind; int x = toWind(wind); if(x == 0){ cout << 'C' << ' ' << 0 << endl; return 0; } cout << calDir(dir+112.5) << ' ' << x << endl; return 0; } string calDir(double dir){ vector<string> str{"N","NNE","NE","ENE","E","ESE","SE","SSE", "S","SSW","SW","WSW","W","WNW","NW","NNW"}; return str.at((int) (dir / 225)); } int toWind(double wind){ double temp = wind / 60.0; int temp2 = (int) (temp * 10 + 0.5); if(temp2 < 2){ return 0; } return calWind(temp2); } int calWind(int wind){ vector<int> bew{15,33,54,79, 107,138,171,207,244, 284,326}; int i; for(i=0;i<11;i++){ if(wind <= bew.at(i)) break; } return i+1; }
Submission Info
Submission Time | |
---|---|
Task | C - 風力観測 |
User | nikka |
Language | C++ (GCC 5.4.1) |
Score | 0 |
Code Size | 1021 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘std::string calDir(double)’: ./Main.cpp:24:24: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 vector<string> str{"N","NNE","NE","ENE","E","ESE","SE","SSE", ^ ./Main.cpp:25:66: error: in C++98 ‘str’ must be initialized by constructor, not by ‘{...}’ "S","SSW","SW","WSW","W","WNW","NW","NNW"}; ^ ./Main.cpp:25:66: error: no matching function for call to ‘std::vector<std::basic_string<char> >::vector(<brace-enclosed initializer list>)’ In file included from /usr/include/c++/5/vector:64:0, from ./Main.cpp:2: /usr/include/c++/5/bits/stl_vector.h:407:9: note: candidate: template<class _InputIterator> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) vector(_InputIterator __first, _InputIterator __last, ^ /usr/include/c++/5/bits/stl_vector.h:407:9: note: template...