面试失败,怀疑是c程序没写对,求大家指正
c语言吧
全部回复
仅看楼主
level 1
0SAS0 楼主
题目如下:
输入一个单通道1000*1000图像,要求将它缩放至200*200。输入输出尺寸是固定的,因此无需写更复杂的双线性插值。给出的函数声明如下
void (unsigned char *inputImg, int imgWidth, int imgHeight, int outWidth, int outHeight, unsigned char *outImg)
下面是我的程序
void (unsigned char *inputImg, int imgWidth, int imgHeight, int outWidth, int outHeight, unsigned char *outImg)
{
outImg = malloc(200*200*1);
for (int oy=0;oy<200;oy++)
{
for (int ox=0;ox<200;ox++)
{
int sum = 0;
for (int iy = oy*5;iy<oy*5+5;iy++)
{
for (int ix = ox*5;ix<ox*5+5;ix++)
{
sum += (int)inputImg[iy*1000+ix];
}
}
sum = sum/25;
outImg[oy*200+ox] = (unsigned char)sum;
}
}
}
因为面试官明确告诉我,输入输出尺寸是固定的,就是1000和200,所以我才没有用输入的WH
然而面试失败了,我怀疑是我这个程序写的有问题。希望大家提点建议
2021年09月29日 04点09分 1
level 7
人都给你函数声明了,你就用人家给你的参数就好了。公司里的业务变化很快的,都这样子按默认值写,还不写注释,还怎么玩?
2021年09月29日 11点09分 2
emm。。如果我程序本身没问题的话,大概这是个问题了。但是是他说,输入输出尺寸固定的= =
2021年09月29日 22点09分
1