4月1日携程笔试
4月1号携程
第一题
#include <iostream>
#include <vector>
#include<string>
#include<sstream>
using namespace std;
int main(void) {
vector<vector<char> >res;
vector <char> vi;
string line;
getline(cin, line);
stringstream ss(line);
vector<string> v;
string x;
while (ss >> x)
{
v.push_back(x);
//cout << x;
}
for (int i = 0;i < v.size();i++)
{
for (int j = 0;j < v[i].size();j++)
{
if (j == 1)
{
if (v[i][j] >= 'a'&&v[i][j] <= 'z')
{
v[i][j] = v[i][j] - 'a' + 'A';
cout << v[i][j];
}
else {
cout << v[i][j];
}
}
else {
cout << v[i][j];
}
}
if (i == v.size()-1)
{ return 0;
}
cout << " ";
}
return 0;
} 第二题 #include <iostream>
#include <vector>
#include <numeric>
#include <limits>
#include<sstream>
using namespace std;
/*请完成下面这个函数,实现题目要求的功能
当然,你也可以不按照下面这个模板来作答,完全按照自己的想法来 ^-^
******************************开始写代码******************************/
bool sumInteger(int a, int b, int c) {
if (a + b == c || a + c == b || b + c == a)
{
return true;
}
return false;
}
/******************************结束写代码******************************/
int main() {
bool res = false;
string line;
getline(cin, line);
stringstream ss(line);
vector<int> v;
int x;
while (ss >> x)
{
v.push_back(x);
}
if (v.size() < 3)
{
cout << "false" << endl;
return 0;
}
for (int i = 0;i < v.size() - 2;i++)
{
for (int j = i + 1;j < v.size() - 1;j++)
{
for (int k = j + 1;k < v.size();k++)
{
res = sumInteger(v[i],v[j],v[k]);
if (res == true)
{
cout << "true"<< endl;
return 0;
}
}
}
}
cout <<"false" << endl;
return 0;
}第三题只过了60%,2 2
0 1 和 1 1
1 1 1 1
的情况容易算重或少算,需改进。图的算法还没怎么看。 
查看10道真题和解析