2019/9/20

# 题目1：

#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main()
{
int t;
cin>>t;
while(t--){
int n;
cin>>n;
string s;
cin>>s;
int l = -1;
for(int j=0; j<s.size(); j++)
{
if(s[j] == '8')
{
l = j;
break;
}
}
if(l == -1)
{
cout<<"NO"<<endl;
continue;
}
else if(s.size()-l < 11)
{
cout<<"NO"<<endl;
continue;
}
else
{
cout<<"YES"<<endl;
continue;
}
}
return 0;
}


# 题目4：

/*
7 5
5 8 10 3 6 10 8
*/
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
//从一个带有空格的输入字符中找出其中的数字
vector<int> get_num(string s){
string s1 =s;
vector<int> res;
while (!s1.empty())
{
if (s1.find(" ") == string::npos)
{
res.push_back(stoi(s1));
s1.clear();
break;
}
string s_temp = s1.substr(0, s1.find(" "));
res.push_back(stoi(s_temp));
s1.erase(0, s1.find(" ") + 1);
}
return res;
}
//找出一个数组当中的非零最小数
int min_vt(vector<int> vt){
vector<int> v2;
for(int i = 0;i<vt.size();i++)
{
if(vt[i] > 0)
v2.push_back(vt[i]);
}
int min = *min_element(v2.begin(),v2.end()) ;
return min;
}
//数组减去其中的非零最小数
vector<int> sub_min(vector<int> vt){
int min = min_vt(vt) ;
for(int i = 0; i<vt.size();i++)
{
if((vt[i]-min)<0) vt[i] = 0;
else vt[i] = vt[i]-min;
}
return vt;
}

int main()
{
string line1,line2;
getline(cin, line1);
getline(cin, line2);
vector<int> res1,res2;
res1 = get_num(line1);
res2 = get_num(line2);
int min;
for(int i = 0; i < res1[1];i++)
{
min =  min_vt(res2);
cout<<min<<endl;
res2 = sub_min(res2);
}

return 0;
}



#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

class Resolution{
public:
int num;
int turns;
vector<int> numArray;
void getData(){
numArray.clear();
cin>>num>>turns;
if(num>0){
for(int i=0;i<num;i++){
int temp;
cin>>temp;
numArray.push_back(temp);
}
}
return;
}
void printData(){
sort(std::begin(numArray), std::end(numArray));
if(turns<=num){
for(int j=0;j<=turns;){
int minNum = numArray[j];
cout<<minNum;
for(int k=j;k<num;k++){
numArray[k] = numArray[k]-minNum;
}
while(numArray[j] ==0 ){
j++;
}
}
}
}
};

int main()
{
Resolution r;
r.getData();
r.printData();
return 0;
}


05-12 6292

04-05 691

09-01 2514

09-12 3228

09-16 722

08-31 6625

03-21 275

09-16 1929

#### 9.16 腾讯笔试编程题ac代码

©️2020 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。