zoukankan      html  css  js  c++  java
  • 2015华为校招机试面试

    昨天参加了华为南研所校招的机试,一共三道题,第一题很简单,输入一个字符串格式的日期,年-月,输出该月有多少天,主要注意闰年((%4==0&&%100!=0)||%400==0)2月的不同;第二题是判断字符串的括号组成正确与否,用栈解决;第三题限定时间,没有做出来,今天问了同学,记录一下:

    /*输入n行m列矩阵,矩阵的每个位置只能是0或1,求最大的正方子矩阵边长,要求子矩阵内皆为1。如输入:
    3 3
    1 1 1
    1 1 1
    0 1 1
    输出:2*/思路主要是在正方矩阵右下角记录大小

     1 #include<iostream>
     2 using namespace std;
     3 
     4 int main()
     5 {
     6   int n,m;
     7   cin>>n>>m;
     8   int **array=new int*[n];
     9   for(int i=0;i<n;i++){
    10     array[i]=new int[m];
    11     for(int j=0;j<m;j++){
    12       cin>>array[i][j];
    13     }
    14   }
    15   int max=0;
    16   for(int i=0;i<n;i++){
    17     for(int j=0;j<m;j++){
    18       if(i>0&&j>0){
    19         int min=array[i-1][j-1];
    20         if(array[i][j-1]<min)min=array[i][j-1];
    21         if(array[i-1][j]<min)min=array[i-1][j];
    22         if(min!=0&&array[i][j]!=0)
    23         array[i][j]+=min;//array[i][j]=min+1;更节省时间
    24       }
    25       if(array[i][j]>max)max=array[i][j];
    26     }
    27  }
    28 34   cout<<max; 35 36   return 0; 37 }

    机试完了,紧接着会有变态的性格测试,难熬的35分钟,选择的时候注意积极乐观和前后一致就行了,不然会被叫重做,无语得很....。通过机试之后,下午就是面试了,一面主要问项目,我被问得很深很细,问了其他同学说是就随便聊聊,二面综合面,就是闲聊了。

  • 相关阅读:
    Use "Attach to Process" in VC Express 2010
    韩国三日游
    可耻的没通过Autodesk 3ds Max初级认证
    Trace depth and rays per second per core
    References on SSS
    Free Shave SDK
    New wisdom on offline/interactive rendering
    匹配汉字的正则表达式
    WPF中richtextbox的一些用法
    C#中禁止一个程序打开多次
  • 原文地址:https://www.cnblogs.com/irun/p/4493066.html
Copyright © 2011-2022 走看看