没有合适的资源?快使用搜索试试~ 我知道了~
将字符串中连续的数字作为一个整数输出_并统计整数的个数
需积分: 29 33 下载量 40 浏览量
2017-02-21
17:32:45
上传
评论 6
收藏 1020B TXT 举报
温馨提示
试读
2页
本文档介绍了如何将字符串中连续的数字作为一个整数输出_并统计整数的个数的方法,附有源代码,可供大家参考
资源推荐
资源详情
资源评论
// suibo.cpp : Defines the entry point for the console application.
//
// suibo.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "string.h"
#include "conio.h"
char a[101][101];
char s[1001];
int _tmain(int argc, _TCHAR* argv[])
{
int i,j;
int m,n;
while(scanf("%s",s)!=EOF)
{
m=0;
int length=strlen(s);
for(i=0;i<length;i++)//对输入串进行处理
{
if(s[i]>=48&&s[i]<=57)//发现第一个为0-9的数
{
for(j=i,n=0;;j++)//把它之后的连续0-9的数记录下来,保存到a中
{
if(s[j]<48||s[j]>57)//遇到非0-9的数,跳出。(因为要是连续的)
break;
a[m][n++]=s[j];
}
m++;//个数加1
//
// suibo.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "string.h"
#include "conio.h"
char a[101][101];
char s[1001];
int _tmain(int argc, _TCHAR* argv[])
{
int i,j;
int m,n;
while(scanf("%s",s)!=EOF)
{
m=0;
int length=strlen(s);
for(i=0;i<length;i++)//对输入串进行处理
{
if(s[i]>=48&&s[i]<=57)//发现第一个为0-9的数
{
for(j=i,n=0;;j++)//把它之后的连续0-9的数记录下来,保存到a中
{
if(s[j]<48||s[j]>57)//遇到非0-9的数,跳出。(因为要是连续的)
break;
a[m][n++]=s[j];
}
m++;//个数加1
资源评论
leon1741
- 粉丝: 1695
- 资源: 112
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功