Submission #288757
Source Code Expand
#include <stdio.h> #include <math.h> #include <string> int main() { int i, Deg, Dis; double vel; const int N_DIR = 16, N_SCAL = 13; const std::string dir[N_DIR] = {"N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"}; const int borderD[N_DIR+1] = {0, 112, 337, 562, 787, 1012, 1237, 1462, 1687, 1912, 2137, 2362, 2587, 2812, 3037, 3262, 3487}; const int scal[N_SCAL] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; const double borderS[N_SCAL+1] = {0.0, 0.3, 1.6, 3.4, 5.5, 8.0, 10.8, 13.9, 17.2, 20.8, 24.5, 28.5, 32.7}; std::string ansD[10]; int ansS; scanf("%d %d", &Deg, &Dis); for(i = 0; i < N_DIR; i++) { if(Deg >= borderD[i] && Deg < border[i+1]) { ansD[0] = dir[i]; break; } } if(Deg >= borderD[N_DIR+1]) ansD[0] = dir[0]; vel = (double)Dis / 60.0; for(i = 0; i < N_SCAL; i++) { if(vel >= borderS[i] && vel < borderS[i+1]) { ansS = scal[i]; break; } } if(ansS == scal[0]) ansD[0] = "C"; printf("%s %d\n", ansD[0].c_str(), ansS); return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - 風力観測 |
User | ne260015 |
Language | C++ (G++ 4.6.4) |
Score | 0 |
Code Size | 1133 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:23:33: error: ‘border’ was not declared in this scope ./Main.cpp:21:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]