c语言 字符串提取连续数字,c语言一串字符串中提取数字并相加的问题

满意答案

dcebd7a0de6265b6ccae5ead692f1eab.png

Letheann

2013.07.19

dcebd7a0de6265b6ccae5ead692f1eab.png

采纳率:41%    等级:13

已帮助:10480人

#include #include "windows.h"#define MAX 1024main(){    char *str1,*str2,*p;    int i=0,k=0;    str1=(char *)malloc(1024*sizeof(char));    str2=(char *)malloc(1024*sizeof(char));    fflush(stdin);    gets(str1);    fflush(stdin);    gets(str2);    p=str1;    while(*p!='\0')    {        if(isdigit(*p)) i=i*10+*p-'0';        p++;    }    p=str2;    while(*p!='\0')    {        if(isdigit(*p)) k=k*10+*p-'0';        p++;    }    printf("%d\n",i+k);    free(str1);    free(str2);}

00分享举报

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值