文章标题
来源:互联网 发布:网络教育学历学费贵 编辑:程序博客网 时间:2024/05/29 17:28
输入一个字符串。
输出字符串中最长的数字字符串和它的长度。如果有相同长度的串,则要一块儿输出,但是长度还是一串的长度
#include<iostream>#include<string>using namespace std;string str;int main(){ while(cin>>str) { int sl=str.size(); if(sl==0) { return NULL; } int temp=0; int maxi=0; int t=0; for(int i=0;i<sl;i++) { if(str[i]-'0'>=0&&str[i]-'0'<=9) { temp++; } else { temp=0; } if(temp>maxi) { maxi=temp; t=i; } } if(t==sl-1) { cout<<str.substr(t+1-maxi,maxi)<<endl; } else{ cout<<str.substr(t-maxi,maxi)<<endl; } cout<<maxi<<endl; } return 0;}
0 0
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- Hibernate各种主键生成策略与配置详解
- 普通用户登录和管理员登录区分
- 【精简版】windows + CUDA + Anaconda + tensorflow
- 理解Java的Thread中的Interrupt机制
- 抽象类和接口的比较
- 文章标题
- android shape 的基本使用
- set排序
- idea
- ANR问题分析
- 游戏运动模糊技术讲解
- Swagger中隐藏API
- C# 事件与委托___窗口间的相互开启与关闭
- Python游戏系列之三_控制飞机移动