Advertisement

华为OD机试真题 C++ 2022 Q4 考勤 | 100分

阅读量:

前言

复制代码
 #include <bits/stdc++.h>

    
  
    
 using namespace std;
    
 vector<int> nums;
    
 vector <string> strings;
    
  
    
 vector <string> getstrings(const std::string &s, char delim)
    
 {
    
     size_t last = 0;
    
     size_t index = s.find_first_of(delim, last);
    
     while (index != std::string::npos) {
    
     strings.push_back(s.substr(last, index - last));
    
     last = index + 1;
    
     index = s.find_first_of(delim, last);
    
     }
    
     if (index - last > 0) {
    
     strings.push_back(s.substr(last, index - last));
    
     }
    

全部评论 (0)

还没有任何评论哟~