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分享举报

你可能感兴趣的:(c语言,字符串提取连续数字)