测试工程师技术笔试--两道编程题
1.递归思想
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <stack>
#include <cctype>
#include <vector>
#include <cmath>
#include <map>
#define ll long long
using namespace std;
ll ans;
ll i;
ll n;
int main()
{
int T;
scanf("%d",&T);
//for(int ccnt=1;ccnt<=T;ccnt++){
while(scanf("%lld",&n) != EOF) {
n--;
i=1;
ans=1;
//printf(" i=%I64d n=%I64d ans=%I64d\n",i,n,ans);
while(n>=i+1)
{
n=n-i-1;
ans+=i-1;
i++;
//printf(" i=%I64d n=%I64d ans=%I64d\n",i,n,ans);
}
ans+=n;
printf("%lld\n",ans);
}
return 0;
}
2,建模
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 100;
int n, m, k, a[N][N], vis[N][N];
int main() {
while (cin >> n >> m >> k) {
memset(a, 0, sizeof(a));
for (int i = 1; i <= k; ++i) {
int x, y;
cin >> x >> y;
a[x][y]++;
}
int ans = 0;
for (int x1 = 1; x1 <= n - 2; ++x1) {
for (int y1 = 1; y1 <= m - 2; ++y1) {
for (int x2 = 1; x2 <= n - 2; ++x2) {
for (int y2 = 1; y2 <= m - 2; ++y2) {
memset(vis, 0, sizeof(vis));
int cur = 0;
for (int ix = x1; ix <= x1 + 2; ++ix) {
for (int iy = y1; iy <= y1 + 2; ++iy) {
vis[ix][iy] = 1;
cur += a[ix][iy];
}
}
for (int ix = x2; ix <= x2 + 2; ++ix) {
for (int iy = y2; iy <= y2 + 2; ++iy) {
if (!vis[ix][iy]) {
cur += a[ix][iy];
}
}
}
ans = max(ans, cur);
}
}
}
}
cout << ans << endl;
}
return 0;
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
面试环节:
一面:
索引 二级索引查找 c++实现
shell 查找含义日期的log文件 并 删除
游标 的定义 书写
二面:
智力题:
怎么较准确的称量人的头的重量
A B 两个小岛各有一人 , B上的人生病了,A上的人有药,AB之间有船,C这个人管理,但他喜欢偷东西,现在AB各有一个钥匙和锁,每人只能开自己的锁,问怎么把药送给B.
HR面:
吹吹牛,聊聊天