Submission #16977

# Submission time Handle Problem Language Result Execution time Memory
16977 2015-11-03T07:03:33 Z taehoon1018 초록색 삼각형 (YDX13_green) C++
Compilation error
0 ms 0 KB
#include <stdio.h>

double area(int x1, int y1, int x2, int y2, int x3, int y3)
{
	double res = (x1*y2 + x2*y3 + x3*y1 - x2*y1 - x3*y2 - x1*y3);
	if (res < 0)
		res = -res;

	return res;
}
int main(void)
{
	int x[2001] = { 0 };
	int y[2001] = { 0 };
	int N = 0,count = 0;
	long double sum = 0;
	srand(5);

	scanf("%d", &N);
	for (int i = 0; i < N; i++)
	{
		scanf("%d%d", &x[i], &y[i]);
	}
	if (N < 3)
	{
		printf("%.12f", 0);
		return 0;
	}
	for (int a = 0; a < N-2;a++)
	{
		for (int b = a+1; b < N - 1;b++)
		{
			for (int c = b+1; c < N;c++)
			{
				sum += area(x[a], y[a], x[b], y[b], x[c], y[c]);
				count++;
			}
		}
	}
	sum /= N;
	sum /= N - 1;
	sum /= N - 2;
	sum *= 3;

	printf("%.12f\n", sum);

	return 0;
}

Compilation message

C.cpp: In function ‘int main()’:
C.cpp:17:9: error: ‘srand’ was not declared in this scope
  srand(5);
         ^
C.cpp:26:20: warning: format ‘%f’ expects argument of type ‘double’, but argument 2 has type ‘int’ [-Wformat=]
   printf("%.12f", 0);
                    ^
C.cpp:45:23: warning: format ‘%f’ expects argument of type ‘double’, but argument 2 has type ‘long double’ [-Wformat=]
  printf("%.12f\n", sum);
                       ^
C.cpp:19:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
                 ^
C.cpp:22:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &x[i], &y[i]);
                              ^