刚才去中软面试了!

guicaisa 2015-06-17 11:42:05
本人非计算机专业。应届毕业生,,前几天刚毕业正在找工作,刚才上午去中软面试了,大家帮我参谋参谋。面试官问了我个问题,父类和子类的关系是啥,我说继承。说完感觉好像说太少了,然后就补充了,公有继承的时候,子类能使用父类的公有接口什么的。感觉还好,然后聊了聊其他方面的。。然后人让我纸上写代码!只在人家口中听过的事情在我身上发生了,有点紧张。在一个字符串中删除出现次数最多的字符。刚开始听着有点蒙,,我说让我想会儿。。过了半分钟看我没啥动静,,面试官说,如果觉得难的话写个冒泡排序吧,,,我当即就感觉情况不妙了啊。冒泡很快的写了出来,一遍写还一遍在想之前那个题怎么写,,,然后突然灵机一动想到方法了。。。先把字符串排序,然后遍历,统计每个相同字符出现的次数,记录每一组相同字符出现的第一字符的迭代器和具体字符,然后如果统计次数大于max,就一溜替换掉。突然就写出来了,虽然纸上写的很乱,,但是通过自己的说明,,算是让面试官理解了。。。但是我回家之后想了想,发现不对!因为排序把原来的字符串顺序改掉了,在冷静的情况,我自己又分析了下,,做了改进,并上机实地操作,并成功!
# include <iostream>
# include <string>
# include <algorithm>
using namespace std;

int main(void)
{
string s = "acabadddddd";
string t(s);
sort(s.begin(), s.end());
char tempc = '\0', maxc;
string::size_type count = 0, max = 0;
string::iterator tempit = s.begin(), maxit;
for (string::iterator it = s.begin(); it != s.end(); ++it)
{
if (*it != tempc)
{
if (count > max)
{
max = count;
maxit = tempit;
maxc = tempc;
}
count = 1;
tempit = it;
tempc = *it;
}
else
count++;
}
if (count > max)//最后一组迭代完之后需要在循环外判断
{
max = count;
maxit = tempit;
maxc = tempc;
}


s.erase(maxit, maxit + max);
string::iterator i = t.begin(), ti;
while ((ti = find(i, t.end(), maxc)) != t.end())
{
i = t.erase(ti);
}

cout << s << endl;
cout << t << endl;

return 0;
}

感觉自己还行啊-。- 虽然我深知自己水平依然很菜!好了,言归正传。问题来了,虽然面试官对我的表现觉得还可以!但是他说我不会数据库,不会linux,技能还有所欠缺,,所以我来此撒分了!求推荐学习linux和oracle的书籍。。。。。。。
...全文
4617 27 打赏 收藏 转发到动态 举报
写回复
用AI写文章
27 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_35743978 2018-12-17
  • 打赏
  • 举报
回复
我刚毕业有一次面试官也要我写个冒泡排序。。。当时我就有点蒙这么简单~稀里糊涂面完后就石沉大海了,后来仔细想了想,这玩意考的其实是优化啊
翅膀又硬了 2015-06-19
  • 打赏
  • 举报
回复
引用 20 楼 u013163178 的回复:

#include <iostream>
#include <string>
#include <cstring>

char fuck(const std::string &str)
{
    int buf[128];
    memset(buf , 0 , sizeof(buf));
    for(auto const &ch : str)
    {
        buf[ch]++;
    }

    int max = buf[0];
    char ch;
    for(size_t i = 0 ; i < sizeof(buf) / sizeof(int) ; ++i)
    {
        if(buf[i] > max)
        {
            max = buf[i];
            ch = i;
        }
    }

    return ch;
}

std::string& bitch(std::string &str , char ch)
{
    for(auto it = str.begin() ; it != str.end() ; )
    {
        if(*it == ch)
        {
            it = str.erase(it);
        }
        else
        {
            ++it;
        }
    }

    return str;
}

int main(void)
{
    //空格最多,会被删除
    std::string str = "hello csdn , you are a fucking website";
    auto ch = fuck(str);
    bitch(str , ch);
    std::cout << str << std::endl;

    return 0;
}
好霸气的函数名
放纵的青春 2015-06-19
  • 打赏
  • 举报
回复
你是来晚了这个论坛 之前这论坛 天天有人骂中软···
寒沙胜雪 2015-06-19
  • 打赏
  • 举报
回复
如果用STL中的话,感觉map<char alphbet,int count> 就可以呢。
stacksoverflow 2015-06-19
  • 打赏
  • 举报
回复
Java学习资料已更新,期待大家的反馈。 内存溢出之JAVA初学教程3(java初级文件操作例子) http://blog.csdn.net/stacksoverflow/article/details/46558033 内存溢出之JAVA初学教程2(Java学习步骤(初级,中级)) http://blog.csdn.net/stacksoverflow/article/details/46533191 内存溢出之JAVA初学教程1(学习前必读) http://blog.csdn.net/stacksoverflow/article/details/46516645
q107770540 2015-06-19
  • 打赏
  • 举报
回复
这种对技术的热情值得鼓励!保持这种习惯,去哪都会混得不错
levenlau 2015-06-18
  • 打赏
  • 举报
回复
引用 16 楼 guicaisa 的回复:
[quote=引用 15 楼 max_min_ 的回复:] you are just a freshman for the company ,So don't worried, taks easy!
我靠,,,版主大人!!我受到了鼓舞!!![/quote] 版主,你英语有点烂吧! don't worry,take it easy!
fly_dragon_fly 2015-06-18
  • 打赏
  • 举报
回复
用map试试
map<char,int> cnt;
    string s = "ffaaaaaaaaaaaccdffgaddfa";
    int ctmax=0,maxchar;
    for(char &ch : s) {
        int &t =cnt[ch];
        if(++t>ctmax){
            ctmax =t;
            maxchar =ch;
        }
    }
    s.erase(remove(s.begin(),s.end(),maxchar),s.end());
usecf 2015-06-18
  • 打赏
  • 举报
回复
个人觉得可以先去,接触的知识也比较广,攒点经验,再去自主研发的公司
li4c 2015-06-18
  • 打赏
  • 举报
回复

#include <iostream>
#include <string>
#include <cstring>

char fuck(const std::string &str)
{
    int buf[128];
    memset(buf , 0 , sizeof(buf));
    for(auto const &ch : str)
    {
        buf[ch]++;
    }

    int max = buf[0];
    char ch;
    for(size_t i = 0 ; i < sizeof(buf) / sizeof(int) ; ++i)
    {
        if(buf[i] > max)
        {
            max = buf[i];
            ch = i;
        }
    }

    return ch;
}

std::string& bitch(std::string &str , char ch)
{
    for(auto it = str.begin() ; it != str.end() ; )
    {
        if(*it == ch)
        {
            it = str.erase(it);
        }
        else
        {
            ++it;
        }
    }

    return str;
}

int main(void)
{
    //空格最多,会被删除
    std::string str = "hello csdn , you are a fucking website";
    auto ch = fuck(str);
    bitch(str , ch);
    std::cout << str << std::endl;

    return 0;
}
假正经的班长 2015-06-17
  • 打赏
  • 举报
回复
肯定会有人劝你不要去中软。 中软薪资水平不算高,而且多数岗位属于外包。
FightForProgrammer 2015-06-17
  • 打赏
  • 举报
回复
apue。unix网络变成。tcp/ip协议
guicaisa 2015-06-17
  • 打赏
  • 举报
回复
引用 15 楼 max_min_ 的回复:
you are just a freshman for the company ,So don't worried, taks easy!
我靠,,,版主大人!!我受到了鼓舞!!!
max_min_ 2015-06-17
  • 打赏
  • 举报
回复
you are just a freshman for the company ,So don't worried, taks easy!
guicaisa 2015-06-17
  • 打赏
  • 举报
回复
引用 13 楼 gzwgyfgpf 的回复:
非计算机专业算是中途出家了,如果真想当程序员的话,刚开始要做好从小公司做起的准备,毕竟跟计算机专业的比起来怎么都要差上一截的,虽然本科教育就那样,但是也不乏高手
我投小公司的简历,,人家面都不叫我过去面试。。。反而中软竟然还喊我去面试。。也可能我的简历写的太烂了。。。
gzwgyfgpf 2015-06-17
  • 打赏
  • 举报
回复
非计算机专业算是中途出家了,如果真想当程序员的话,刚开始要做好从小公司做起的准备,毕竟跟计算机专业的比起来怎么都要差上一截的,虽然本科教育就那样,但是也不乏高手
失散糖 2015-06-17
  • 打赏
  • 举报
回复
引用 7 楼 JiangWenjie2014 的回复:
没有人一毕业什么都会的,而且不建议去外包,网上的评价总体来说不好。学习linux的话,unix环境高级编程,里面讲最基础的API,使用的话,你虚拟机里面安装个CentOS就可以开始学习了。另外,看到你的题目,用了排序,其实完全不需要排序的哦。

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main ()
{
    const char *input = "acabadddddd";

    char *out;
    const unsigned char *ptr = input;
    int table[256] = {0}, max = 0, i;
    
    while (*ptr) {
        table[*ptr++]++;
    }

    for (i = 1; i < 256; ++i) {
        if (table[max] < table[i])
            max = i;
    }

    out = malloc (ptr - input - table[max] + 1);

    for (i = 0, ptr = input; *ptr; ++ptr) {
        if (*ptr != max) {
            out[i++] = *ptr;
        }
    }
    out[i] = '\0';

    printf ("%s\n%s\n", input, out);

    free (out);

    return 0;
}
传说中的桶排序
guicaisa 2015-06-17
  • 打赏
  • 举报
回复
引用 7 楼 JiangWenjie2014 的回复:
没有人一毕业什么都会的,而且不建议去外包,网上的评价总体来说不好。学习linux的话,unix环境高级编程,里面讲最基础的API,使用的话,你虚拟机里面安装个CentOS就可以开始学习了。另外,看到你的题目,用了排序,其实完全不需要排序的哦。

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main ()
{
    const char *input = "acabadddddd";

    char *out;
    const unsigned char *ptr = input;
    int table[256] = {0}, max = 0, i;
    
    while (*ptr) {
        table[*ptr++]++;
    }

    for (i = 1; i < 256; ++i) {
        if (table[max] < table[i])
            max = i;
    }

    out = malloc (ptr - input - table[max] + 1);

    for (i = 0, ptr = input; *ptr; ++ptr) {
        if (*ptr != max) {
            out[i++] = *ptr;
        }
    }
    out[i] = '\0';

    printf ("%s\n%s\n", input, out);

    free (out);

    return 0;
}
大哥你这个方法好简便!学习一记。我当时真是慌的要死,,,还好一下子想到了一个方法。。。
kuankuan_qiao 2015-06-17
  • 打赏
  • 举报
回复
鸟哥的私房菜
shiguojie19892 2015-06-17
  • 打赏
  • 举报
回复
引用 8 楼 shiguojie19892 的回复:
中软的待遇和二线城市一个价
忘了回答问题: 你可以学习一下mysql ,官网有linux版本的mysql ,网上有教程怎么安装linux,怎么安装mysql-linux,可以再在linux下编写程序调用mysql的api试着学习。mysql基本的语法比c++语法少多了,容易上手。随便找本mysql的书看看就可以。
加载更多回复(6)

64,645

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧