#include <stdio.h>
#include <math.h>
char *kakudo(double d) {
if (11.25 <= d && d < 33.75) return "NNE";
else if (33.75 <= d && d < 56.25) return "NE";
else if (56.25 <= d && d < 78.75) return "ENE";
else if (78.75 <= d && d < 101.25) return "E";
else if (101.25 <= d && d < 123.75) return "ESE";
else if (123.75 <= d && d < 146.25) return "SE";
else if (146.25 <= d && d < 168.75) return "SSE";
else if (168.75 <= d && d < 191.25) return "S";
else if (191.25 <= d && d < 213.75) return "SSW";
else if (213.75 <= d && d < 236.25) return "SW";
else if (236.25 <= d && d < 258.75) return "WSW";
else if (258.75 <= d && d < 281.25) return "W";
else if (281.25 <= d && d < 303.75) return "WNW";
else if (303.75 <= d && d < 326.25) return "NW";
else if (326.25 <= d && d < 348.75) return "NNW";
else return "N";
}
char * hougaku[] = {"NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW","N"};
char * kakudo2(double d) {
int i;
for (i = 0; i < 15; i++) {
if (1125 + i*2250 <= d*10 && d*10 < 1125 + (i+1)*2250)
return hougaku[i];
}
return hougaku[15];
}
int wind(double w) {
if (0 <= w && w <= 0.2) return 0;
else if (0.3 <= w && w <= 1.5) return 1;
else if (1.6 <= w && w <= 3.3) return 2;
else if (3.4 <= w && w <= 5.4) return 3;
else if (5.5 <= w && w <= 7.9) return 4;
else if (8.0 <= w && w <= 10.7) return 5;
else if (10.8 <= w && w <= 13.8) return 6;
else if (13.9 <= w && w <= 17.1) return 7;
else if (17.2 <= w && w <= 20.7) return 8;
else if (20.8 <= w && w <= 24.4) return 9;
else if (24.5 <= w && w <= 28.4) return 10;
else if (28.5 <= w && w <= 32.6) return 11;
else if (32.7 <= w) return 12;
}
double windkyokai[][12] = {
{0 ,0.2},
{0.3 ,1.5},
{1.6 ,3.3},
{3.4 ,5.4},
{5.5 ,7.9},
{8.0 ,10.7},
{10.8 ,13.8},
{13.9 ,17.1},
{17.2 ,20.7},
{20.8 ,24.4},
{24.5 ,28.4},
{28.5 ,32.6}
};
double windkyokai2[] = {
0,
0.25,
1.55,
3.35,
5.45,
7.95,
10.75,
13.85,
17.15,
20.75,
24.45,
28.45,
32.65};
int wind2(double w) {
int i;
for (i = 0; i < 12; i++) {
if ((int)((windkyokai[i][0]-0.05)*60) <= w && w < (int)((windkyokai[i][1]+0.05)*60)) return i;
}
return 12;
}
int wind3(double w) {
int i;
for (i = 0; i < 12; i++) {
if((int)(windkyokai2[i]*60)<=w&&w<(int)(windkyokai2[i+1]*60)) return i;
}
return 12;
}
int main() {
double deg,dis;
scanf("%lf %lf", °, &dis);
//printf("%lf %lf\n",deg,dis);
char *dir;
int w;
//printf("%lf %lf\n",deg/10,round(dis/60*10)/10);
dir = kakudo2(deg);
w = wind3(dis);
if (w == 0) printf("C 0\n");
else printf("%s %d\n",dir,w);
return 0;
}
./Main.c: In function ‘main’:
./Main.c:97:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lf %lf", °, &dis);
^