比特大陆 算法

一面

2021-10-8

项目

代码

矩阵乘法

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int compute_matrix(const vector<vector<int>>& mat1, const vector<vector<int>>& mat2, vector<vector<int>>& res ){
    int m1 = mat1.size();
    int n1  = mat1[0].size();
    int m2 = mat2.size();
    int n2 = mat2[0].size();
    if(n1!=m2){
        return -1;
    }
    res.clear();
    for(int i = 0; i<m1; i++){
        res.push_back(vector<int>(n2, 0));
    }

    for(int i = 0; i<m1; i++){
        for(int j = 0; j<n2; j++){
            for(int k =0; k<m2; k++){
                res[i][j]+=mat1[i][k]+mat2[k][j];            
            }
        }
    }

    return 1;

}

int main() {
    //int a;
    //cin >> a;
    vector<vector<int>> mat1 = {{1,1},
                                {1,1}};
    vector<vector<int>> mat2 = {{2,2}, 
                                {2,2}};
    vector<vector<int>> res;
    auto f = compute_matrix(mat1, mat2, res);
    for(const auto& line:res){
        for_each(line.begin(), line.end(), [](int a){cout << a << " ";});
        cout << endl;
    }
    cout << "Hello World!" << endl;
}

C++基础

1、static关键字
对普通函数声明static关键字,只能当前文件内部使用,对外隐藏

静态全局变量(或者函数)在声明它的整个文件都是可见的,而在文件之外是不可见的; 

2、拷贝构造

#比特大陆##笔经#
全部评论
一面写代码吗
点赞 回复 分享
发布于 2021-10-22 15:41
楼主通过了没 有消息吗
点赞 回复 分享
发布于 2021-10-08 21:01
楼主1面多长时间?
点赞 回复 分享
发布于 2021-10-08 14:01

相关推荐

暴杀流调参工作者:春招又试了一些岗位,现在投递很有意思,不仅要精心准备简历,投递官网还得把自己写的东西一条一条复制上去,阿里更是各个bu都有自己的官网,重复操作无数次,投完简历卡完学历了,又该写性格测评、能力测评,写完了又要写专业笔试,最近还有些公司搞了AI辅助编程笔试,有些还有AI面试,对着机器人话也听不明白录屏硬说,终于到了人工面试又要一二三四面,小组成员面主管面部门主管面hr面,次次都没出错机会,稍有不慎就是挂。 卡学历卡项目卡论文卡实习什么都卡,没有不卡的😂
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
1
7
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务