#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int U(int x, int y);
int U(int x, int y)
{return x*y;}
int main(void)
{
int x[2],y[2],i;
int tmp_x0 , tmp_x1 , tmp_y0 , tmp_y1 ;
/* A가 가진 재화량과 B가 가진 재화량을 입력하시오 */
printf("input number of x and y that belongs to 'A'\n");
scanf("%d%d",&x[0],&y[0]);
fflush(stdin);
printf("input number of x and y that belongs to 'B'\n");
scanf("%d%d",&x[1],&y[1]);
printf("%d,%d,%d,%d\n",x[0],y[0],x[1],y[1]);
/* A: "x 줄게 y내놔" B:"y줄게 x내놔" 파레토 최적일때까지 진행 */
while(1)
{
tmp_x0 = x[0]; tmp_x1 = x[1]; tmp_y0 = y[0]; tmp_y1 = y[1];
for (i=0; i<=y[1]; ++i)
if ((U(x[0]-1,y[0]+y[1]-i) >= U(x[0],y[0]) && U(x[1]+1,i) > U(x[1],y[1]))
|| (U(x[0]-1,y[0]+y[1]-i) > U(x[0],y[0]) && U(x[1]+1,i) >= U(x[1],y[1])))
{
x[0]=x[0]-1;
x[1]=x[1]+1;
y[0]=y[0]+y[1]-i;
y[1]=i;
break;
}
for(i=0; i<=x[0]; ++i)
if( (U(x[1]+x[0]-i,y[1]-1) >= U(x[1],y[1]) && U(i,y[0]+1) > U(x[0],y[0]) )
|| (U(x[1]+x[0]-i,y[1]-1) > U(x[1],y[1]) && U(i,y[0]+1) >= U(x[0],y[0])))
{
x[1]=x[1]+x[0]-i;
x[0]=i;
y[0]=y[0]+1;
y[1]=y[1]-1;
break;
}
if( tmp_x0 == x[0] && tmp_x1 == x[1] && tmp_y0 == y[0] && tmp_y1 == y[1] )
break;
}
/* A: "y 줄게 x 내놔" B: "x줄게 y내놔" 파레토 최적일때까지 진행 */
while(1)
{
tmp_x0 = x[0]; tmp_x1 = x[1]; tmp_y0 = y[0]; tmp_y1 = y[1];
for (i=0; i<=x[1]; ++i)
if( (U(x[0]+x[1]-i,y[0]-1) > U(x[0],y[0]) && U(i,y[1]+1) >= U(x[1],y[1]) )
||(U(x[0]+x[1]-i,y[0]-1) >= U(x[0],y[0]) && U(i,y[1]+1) > U(x[1],y[1])) )
{
코드 읽기가 힘들다 이항연산자 사이는 띄우는게 좋아
int U(int x, int y); int U(int x, int y) {return x*y;} 이렇게 쓸거면 궂이 prototype를 써야했을까 싶고
fflush(stdin); 이거 비표준이니까 제발 쓰지마
너무 보기힘든데
궂이 -> 굳이임