华为2015合肥机试
来源:互联网 发布:淘宝武汉飞鱼 编辑:程序博客网 时间:2024/04/27 20:39
//华为机试第一题:取十个数字(可重复)中不重复的最大三位数,构成最大三位数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// 1void 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 0
- 华为2015合肥机试
- 华为2014校园招聘合肥机试
- 上海合肥地区华为2015年校园招聘研发类岗位机试题:
- 日期问题(华为2014年机试题——合肥——之三)
- 数的分解(华为2014年机试题——合肥——之一)
- 2015华为机试
- 2015合肥国际机器人与自动化展览会
- 2015合肥机床及金属加工机械展览会
- 2015中国(合肥)电源工业展览会
- 2015合肥空压机及气动技术展览会
- 2015合肥国际五金机电展览会
- 2015Robocup --机器人世界杯(合肥)
- hdu5492(2015合肥网络赛I题)
- hdu5491(2015合肥网络赛H题)
- hdu5489(2015合肥网络赛F题)
- 2015中国计算机大会在合肥举行
- [刷题]ACM ICPC 2015合肥网络赛
- 2015华为校园招聘 机试总结
- 聚类算法总结
- Openfire服务器简要评测
- Java集合框架(J2SE1.6)
- Deruio制作 wiringPi用户手册V001
- 基于S5pc100 处理器的ADC驱动
- 华为2015合肥机试
- android手机获取联系人姓名和电话号码
- 链表的环问题
- Div 自适应屏幕大小
- 知识图谱演进
- c#中Main函数的4中格式
- 从图谱搜索看搜索技术的发展趋势
- oracle 11g r2 emca重建
- LeetCode:Maximum Depth of Binary Tree