제출 #16032

#제출 시각아이디문제언어결과실행 시간메모리
16032ainu7미술 수업 (IOI13_artclass)C++98
컴파일 에러
0 ms0 KiB
#include <algorithm> #include <vector> #include "artclass.h" using namespace std; const double PI = 3.141592653589793238; void avestd(int H, int W, int R[500][500], int G[500][500], int B[500][500], int step, double res[6]) { int cnt = 0; double r_sum = 0, g_sum = 0, b_sum = 0; double r_sq = 0, g_sq = 0, b_sq = 0; for ( int i = step; i<H; i+=step ) for ( int j = step; j<W; j+=step) { cnt += 2; int rr = R[i][j] - R[i][j-step]; int gg = G[i][j] - G[i][j-step]; int bb = B[i][j] - B[i][j-step]; r_sum += abs(rr); g_sum += abs(gg); b_sum += abs(bb); r_sq += rr*rr; g_sq += gg*gg; b_sq += bb*bb; rr = R[ i ][ j ] - R[ i - step ][ j ]; gg = G[ i ][ j ] - G[ i - step ][ j ]; bb = B[ i ][ j ] - B[ i - step ][ j ]; r_sum += abs(rr); g_sum += abs(gg); b_sum += abs(bb); r_sq += rr*rr; g_sq += gg*gg; b_sq += bb*bb; } res[0] = r_sum / cnt; res[1] = g_sum / cnt; res[2] = b_sum / cnt; res[3] = sqrt(( r_sq - ( r_sum / cnt )*r_sum ) / cnt); res[4] = sqrt(( g_sq - ( g_sum / cnt)*g_sum ) / cnt); res[5] = sqrt(( b_sq - ( b_sum / cnt )*b_sum ) / cnt); } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { double P[100][6]; avestd(H, W, R, G, B, 1, P[ 1 ]); avestd(H, W, R, G, B, 3, P[ 3 ]); avestd(H, W, R, G, B, 10, P[ 10 ]); // printf("%f %f %f %f %f %f\n", P[ 1 ][ 0 ], P[ 1 ][ 1 ], P[ 1 ][ 2 ], P[ 1 ][ 3 ], P[ 1 ][ 4 ], P[ 1 ][ 5 ]); // printf("%f %f %f %f %f %f\n", P[ 3 ][ 0 ], P[ 3 ][ 1 ], P[ 3 ][ 2 ], P[ 3 ][ 3 ], P[ 3 ][ 4 ], P[ 3 ][ 5 ]); // printf("%f %f %f %f %f %f\n", P[ 10 ][ 0 ], P[ 10 ][ 1 ], P[ 10 ][ 2 ], P[ 10 ][ 3 ], P[ 10 ][ 4 ], P[ 10 ][ 5 ]); if (P[10][0] + P[10][1] + P[10][2] < 40 && P[10][3] + P[10][4] + P[10][5] < 80) return 4; double dd = P[10][0] / P[1][0] + P[10][1] / P[1][1] + P[10][2] / P[1][2]; if (dd > 9) return 1; if (P[10][0] + P[10][1] + P[10][2] > 110) return 3; return 2; }

컴파일 시 표준 에러 (stderr) 메시지

artclass.cpp: In function 'void avestd(int, int, int (*)[500], int (*)[500], int (*)[500], int, double*)':
artclass.cpp:40:11: error: 'sqrt' was not declared in this scope
  res[3] = sqrt(( r_sq - ( r_sum / cnt )*r_sum ) / cnt);
           ^~~~
artclass.cpp:40:11: note: suggested alternative: 'qsort'
  res[3] = sqrt(( r_sq - ( r_sum / cnt )*r_sum ) / cnt);
           ^~~~
           qsort