華為筆試及面試經歷
阿新 • • 發佈:2019-01-26
1.大數相乘
#include<iostream>
#include<cstdio>
#include<math.h>
using namespace std;
int multiply (const std::string sA,const std::string sB, std::string &res)
{
/* 在這裡實現功能 */
string A = sA;
string B = sB;
int a = A.length();
int b = B.length();
int reslen = 0 ;
int c = (a+1)*(b+1);
int *p = new int[c];//逆序存放的結果
int *pA = new int[a];//逆序存放的乘數A
int *pB = new int[b];//逆序存放的乘數B
//測試是否有乘數為空
if ((a == 0) || (b == 0))
return -1;
for (int i = 0; i != c; i++)
p[i] = 0;
for (string::size_type index = 0; index != A.length(); index++)
pA[a-1 -index] = A.at(index) - '0';
for (string::size_type index = 0; index != B.length(); index++)
pB[b-1-index] = B.at(index) - '0';
for (int temp_b = 0; temp_b != b; temp_b++)
{
for (int temp_a = 0; temp_a != a; temp_a++)
{
int temp = p[temp_a+temp_b] + pA[temp_a]*pB[temp_b];
p[temp_a+temp_b] = temp % 10 ;
int carry = temp/10;
int x = temp_a + temp_b +1;
while(carry != 0)//進位不等於0
{
p[x] = p[x] + carry%10;
carry = carry/10;
x++;
}
}
}
while (c-- > 0) //判斷結果有幾位
{
if (p[c] != 0)
{
reslen = c + 1;
break;
}
}
char ch;
for (int i = reslen - 1; i >= 0 ; i--) //把結果放入字串中
{
ch = p[i] + '0';
res.push_back(ch);
}
if (res.empty())//如果結果為0,則輸出字串為“0”
{
res= "0";
}
return 0;
}
int main(void)
{
string sA;
cin>>sA;
string sB;
cin>>sB;
string res = "\0";
multiply (sA,sB,res);
cout <<res<<endl;
return 0;
}
2.面試經歷:
一面:
1.自我介紹
2.介紹專案
3.寫快排,插入排序
4.面試官介紹部門(感覺是做開發的,可是我面的演算法工程師)
5.學了哪些課程
反正。。。不難。。。
二面:
1.本科和碩士學校的區別
2.介紹專案
3.閒聊。。。二面的面試官沒怎麼為難我,我室友面二面的時候被各種問題狂轟濫炸,什麼優缺點,專案角色,專案難點什麼的各種。
4.有什麼想問的