人工智能大数据,工作效率生产力
Ctrl + D 收藏本站,更多好用AI工具
当前位置:首页 » AI资讯

上海人工智能实验室面试题

2024-07-17 43

来源:投稿 作者:LSC
编辑:学姐

匿名定义一个目标函数或者函数对象,不需要额外的再写一个命名函数或者函数对象,以更直接的方式去写函数,可以调高程序的可读性和可维护性。

和python的用法是类似的。但是我C++用lambda比较少,是属于C++11后的语法。

我不太会,模板太久没用了,后来重新查了一下。

语法格式如下:

template <class 类型参数1, class类型参数2, …

返回值类型 模板名(形参表)

函数体

template<class T> void sum(T *array, int size) { T sum = 0; for(int i = 0; i < size; ++i) { sum += array[i]; } return sum; } 
#define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<cstdio> #include<string> #include<queue> #include<stack> #include<unordered_map> #include<unordered_set> #include<algorithm> #include<map> #include<vector> using namespace std; struct Node { int data; Node *lchild, *rchild; Node(int d, Node *l = NULL, Node *r = NULL) : data(d), lchild(l), rchild(r) {} }; void bfs(Node *root) { queue<Node*> q; q.push(root); while (!q.empty()) { Node* temp = q.front(); q.pop(); printf("%d\n", temp->data); if (temp->lchild != NULL) { q.push(temp->lchild); } if (temp->rchild != NULL) { q.push(temp->rchild); } } } 

比如{{{()[]{}}}}是对的,{{[}}]是错的

#define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<cstdio> #include<string> #include<queue> #include<stack> #include<unordered_map> #include<unordered_set> #include<algorithm> #include<map> #include<vector> using namespace std; string str; stack<char> s; bool check(string &str) { int len = str.length(); for (int i = 0; i < len; ++i) { if (str[i] == '{' || str[i] == '[' || str[i] == '(') { s.push(str[i]); } else { if (str[i] == '}') { if (s.empty() || s.top() != '{') return false; s.pop(); } else if (str[i] == ']') { if (s.empty() || s.top() != '[') return false; s.pop(); } if (str[i] == ')') { if (s.empty() || s.top() != '(') return false; s.pop(); } } } return true; } int main() { cin >> str; if (check(str))cout << 1 << endl; else cout << 0 << endl; return 0; } 

最后聊了关于模型部署的工作和学习路线,以及行业前景。

更多面经可关注👇不定期分享各类资料合集

原文链接:https://blog.csdn.net/weixin_42645636/article/details/128418272?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522171851498716800184179110%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=171851498716800184179110&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-6-128418272-null-null.nonecase&utm_term=AI%E9%9D%A2%E8%AF%95

相关推荐

阅读榜

hellenandjeckett@outlook.com

加入QQ群:849112589

回顶部