当前位置:   article > 正文

华为2018校招_华为校招定级表

华为校招定级表

题目1

题目描述
请一个在字符串中找出连续最长的数字串,并把这个串的长度返回;如果存在长度相同的连续数字串,返回最后一个连续数字串;
注意:数字串只需要是数字组成的就可以,并不要求顺序,比如数字串“1234”的长度就小于数字串“1359055”,如果没有数字,则返回空字符串(“”)而不是NULL!(说明:不需要考虑负数)
输入描述:
字符串
输出描述:
连续数字串&在所有数字串最长的长度
示例1
输入
abcd12345ed125ss123058789
输出
123058789
9

#include <iostream>
#include <string>
#include <algorithm>
#include <ctype.h>

bool legal( char ch ) { return isdigit(ch); }
bool illegal( char ch ) { return !legal(ch); }

void resolve_line( std::string& line, std::string& pat );

int main(void){
    std::string line;
    while(std::cin >> line){
        std::string ans = "";
        resolve_line(line, ans);
        if(ans != ""){
            std::cout << ans << std::endl
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/224087
推荐阅读
相关标签
  

闽ICP备14008679号