发布于 2014-10-15 13:58:02 | 1004 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

华为

华为技术有限公司是一家生产销售通信设备的民营通信科技公司,总部位于中国广东省深圳市龙岗区坂田华为基地。华为的产品主要涉及通信网络中的交换网络、传输网络、无线及有线固定接入网络和数据通信网络及无线终端产品,为世界各地通信运营商及专业网络拥有者提供硬件设备、软件、服务和解决方案。华为于1987年在中国深圳正式注册成立。


华为机试第一题:取十个数字(可重复)中不重复的最大三位数,构成最大三位数   

参考答案:

void main()  
{  
    int num[10];  
    for(int i = 0; i < 10;++i)  
    {  
        num[i] = 0;  
    }  
    int index = 0;  
    for(int i = 0; i < 10; ++i)  
    {  
        std::cin>>index;  
        num[index]++;  
    }  
    int max = 0;  
    int count = 0;  
    for(int i = 9; count != 3 && i >= 0; --i)  
    {  
        if(num[i] != 0)  
        {  
            max = max * 10 + i;  
            count++;  
        }  
    }  
    std::cout<<max<<std::endl;  
    system("pause");  

 

第二题:确定最小需要拆开盒子个数,包含多组输入  

输入: <<<A>>><>  
       <A>  
输出: 3  
       1  

参考答案:


void main()  
{  
    std::string str;  
    int arr[50];//对个数进行统计  
    int com = 0;  
    while(std::cin>>str)  
    {  
        int len = str.length();  
        int count = 0;  
        int travel = 0;  
        while(str[travel] != 'A' && travel != len)  
        {  
            if(str[travel] == '(')  
                count++;  
            else if(str[travel] == ')')  
                count--;  
            travel++;  
        }  
        arr[com++] = count;  
    }  
    for(int i = 0; i < com; ++i)  
    {  
        std::cout<<arr[i]<<std::endl;  
    }  
    system("pause");  

第三题,和尚挑水,七个和尚,一周七天。每个人的安排挑水时间不同,输出所有的跳水可能排列组合  

输入:0 表示该和尚当天不可挑水, 1 表示该和尚当天可挑水  
输入:1 0 1 0 1 0 1  
      0 1 0 1 0 1 0  
      ....  
输出 4  
     1 2 3 5 4 6 7  
     ....  

参考答案:

int stack[7];  
std::vector<int*> stack_record;  
std::set<int> mon;  
int count = 0;  
void findNext(int record[7][7],int depth)  
{  
    if(depth == 7)  
    {  
        count++;  
        int* numPtr = new int[7];  
        for(int i = 0; i < 7; ++i)  
        {  
            numPtr[i] = stack[i] + 1;  
        }  
        stack_record.push_back(numPtr);  
    }  
    else  
    {  
        for(int i = 0; i < 7;i++)  
        {  
            if(record[i][depth] == 1 && mon.count(i) == 0)  
            {  
                stack[depth] = i;  
                mon.insert(i);  
                findNext(record,depth+1);  
                mon.erase(i);  
            }  
        }  
    }  
}  
void main()  
{  
    int record[7][7];  
    for(int i = 0; i < 7; ++i)  
    {  
        for(int j = 0; j < 7; ++j)  
        {  
            std::cin>>record[i][j];  
        }  
    }  
    findNext(record,0);  
    std::cout<<stack_record.size()<<std::endl;  
    for(int i = 0; i < stack_record.size(); ++i)  
    {  
        int *tmp = stack_record[i];  
        for(int j = 0; j < 7; ++j)  
        {  
            std::cout<<tmp[j]<<" ";  
        }  
        std::cout<<std::endl;  
    }  
    system("pause");  
}



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务