作者cyBochu (Fathome)
看板C_and_CPP
标题[问题] C语言题目请益
时间Wed Sep 12 17:39:45 2018
各位C/C++的高手们好
想请问下面这段C语言程式要如何优化
希望能给我这样优化的原因,感谢
编译平台不限
-----------------------------------分隔线-------------------------------------
#define WHITE 255
#deifne BLACK 0
#deinfe THRESHOLD 20
#define WINDOW_HEIGHT 5
#define BOOL int
#define TRUE 1
#define FALSE 0
BOOL funtionFromRight(int score, int width, byte * * image, int xi, int yi)
{
BOOL b;
int leftBound = 2;
for(b=xi-1; b > leftBound && b < width-2 ; b=b-1)
{
if(image[yi][b] == WHITE && image[yi][b+1] == BLACK)
{
int isVertical=0;
for(int c = WINDOW_HEIGHT*(-1); c <= WINDOW_HEIGHT ; c++)
{
isVertical+=image[yi+c][b_next];
isVertical+=image[yi+c][b];
}
if(isVertical <= THRESHOLD && score > 200)
return TRUE;
}
if(image[yi] [b] == BLACK)
break;
}
return FALSE;
}
BOOL funtionFromLeft(int score, int width, byte * * image, int xi, int yi)
{
BOOL b;
int leftBound = 2;
for(b=xi+1; b > leftBound && b < width-2 ; b=b+1)
{
if(image[yi][b] == WHITE && image[yi][b+1] == BLACK)
{
int isVertical=0;
for(int c = WINDOW_HEIGHT*(-1); c <= WINDOW_HEIGHT ; c++)
{
isVertical+=image[yi+c][b_next];
isVertical+=image[yi+c][b];
}
if(isVertical <= THRESHOLD && score > 200)
return TRUE;
}
if(image[yi][b] == BLACK)
break;
}
return FALSE;
}
------------------------------分隔线------------------------------------------
上面是此段程式
先感谢各位高手了
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 59.115.152.122
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/C_and_CPP/M.1536745188.A.A6C.html
1F:→ MOONRAKER: 希望你说明这样问的原因。 09/12 17:47
2F:嘘 MOONRAKER: 感谢。 09/12 18:00
3F:推 god145145: -O3 09/12 18:26
4F:推 chuegou: 名称优化和排版优化可以吗 或是楼上的编译优化? 09/12 19:18
5F:嘘 ko27tye: 作业自己写 09/12 21:16
6F:→ feeya: 这啥阿 影像处理还是专题之类的 09/14 22:13