一亩三分地论坛

 找回密码
 获取更多干货,去instant注册!

扫码关注一亩三分地公众号
查看: 939|回复: 3
收起左侧

Futurex firmware software 筛选题求助

[复制链接] |试试Instant~ |关注本帖
donghaox 发表于 2016-7-4 01:06:57 | 显示全部楼层 |阅读模式

2016(7-9月) 码农类 本科 全职@Futurex - 网上海投 - HR筛选 在线笔试 |Otherfresh grad应届毕业生

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看,没有帐号?获取更多干货,去instant注册!

x
各路大神, 学霸,程序员们好不太确定应该发在求职一栏还是刷题一栏比较好,我最近投futurex 的 entry level firware SW,他们的HR回了我一封面试题,说实话,我对C++还不是太熟,所以也没油什么思路,所以想请地里的人看看~. 鐗涗汉浜戦泦,涓浜╀笁鍒嗗湴
. From 1point 3acres bbs
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/time.h>. visit 1point3acres.com for more.

typedef int int32;
typedef unsigned char int8;
. 涓浜-涓夊垎-鍦帮紝鐙鍙戝竷
static void integrate_arrays(int8  *output, int8  *input_1, const int8  *input_2, int32 length)
{
    int32 i = 0;
. more info on 1point3acres.com
    for(i=0; i<length; i++)
    {
        output = (int8)(input_1 ^ input_2);.鏈枃鍘熷垱鑷1point3acres璁哄潧
    }

    return;
}

static void itoa( int32 num, int8  *alpha, int32 radix ) 鏉ユ簮涓浜.涓夊垎鍦拌鍧.
{
    if( radix == 10 )
    {
        sprintf(alpha, "%i", num);
    }. 1point3acres.com/bbs
    else if( radix == 16 )
    {
        sprintf(alpha, "%X", num);
    }
}

int8 *gen_modified_key(int8 modifier, const int8  *input_1, int32 length)
{. 涓浜-涓夊垎-鍦帮紝鐙鍙戝竷
    int8  leading[3];
    int32 i_leading;
    int8 * temp_string = NULL;
    int8 * ret;.鏈枃鍘熷垱鑷1point3acres璁哄潧
    int32 i = 0;

    itoa(modifier/2, leading, 10);
    i_leading = atoi(leading);
    temp_string = (int8 *) malloc(8);
    ret = (int8 *) malloc(length);
    memset(temp_string, 0, 8);. visit 1point3acres.com for more.
    temp_string[0] = 0;

    if( (modifier+1)%2 == 0 ) {
        temp_string[0] = (int8)((i_leading<<4) + 8);
    }   .鏈枃鍘熷垱鑷1point3acres璁哄潧
    else {. more info on 1point3acres.com
        temp_string[0] = (int8)(i_leading<<4);
    }   

    for(i=0; i<(length>>3); i++)
    {
        integrate_arrays(ret+i*8, temp_string, input_1+i*8, 8);
    }   
    free(temp_string);. 1point3acres.com/bbs
    return ret;
}   
.鐣欏璁哄潧-涓浜-涓夊垎鍦
// Do not change anything in main 鏉ユ簮涓浜.涓夊垎鍦拌鍧.
// main only contains example input
// Change anything else
int main(int argc, char **argv) {. From 1point 3acres bbs

    // Example input data
    int8 data[32] = { 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,. visit 1point3acres.com for more.
                     17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32};
    int8 *resp = gen_modified_key(0x10, data, sizeof(data));
    free(resp);

    return 0;. from: 1point3acres.com/bbs
}

1.  What does the function gen_modified_key do?
2.  What problems or issues, if any, do you see with it?
3.  How could you improve the function, and what benefits would your improvements make?
4.  What other additional improvements could you make to the rest of the code?

In addition to answering the above questions in your response, we would also like you to re-write the code to incorporate your improvements. I would like to point out that the code is intentionally flawed and not indicative of our overall code quality. We would like you to improve it to make the function more efficient while ensuring the input parameters are the same, and the output matches what it would have been before your changes. We are looking for you to only make efficiency improvements, not changes related to security or functionality.

这个挺长的,可能不是太难,大家多多讨论,futurex他们公司在扩招,都是entry level SW 而且都是这道题, 希望地里的人都有希望进去
. 鐣欏鐢宠璁哄潧-涓浜╀笁鍒嗗湴


 楼主| donghaox 发表于 2016-7-5 05:11:42 | 显示全部楼层
真的没有人看一眼吗。。。。
回复 支持 反对

使用道具 举报

Druss 发表于 2016-7-30 02:27:29 | 显示全部楼层
我昨天拿到了和你一样的题,请问你解决了么
回复 支持 反对

使用道具 举报

 楼主| donghaox 发表于 2016-8-3 02:02:34 | 显示全部楼层
Druss 发表于 2016-7-30 02:27
我昨天拿到了和你一样的题,请问你解决了么

没有呀, 我对C不是很熟, 所有就放弃了,不过这个好心没有时间限制
回复 支持 反对

使用道具 举报

本版积分规则

请点这里访问我们的新网站:一亩三分地Instant.

Instant搜索更强大,不扣积分,内容组织的更好更整洁!目前仍在beta版本,努力完善中!反馈请点这里

关闭

一亩三分地推荐上一条 /5 下一条

手机版|小黑屋|一亩三分地论坛声明 ( 沪ICP备11015994号 )

custom counter

GMT+8, 2016-12-11 14:33

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

快速回复 返回顶部 返回列表