1个回答
2018-04-08 · 知道合伙人互联网行家
关注
展开全部
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(void)
{
int i, n, len;
n = 0;
char s2[50];
char s1[] = "Hello World 123";
len = strlen(s1);
for(i = 0; i < len; i++)
{
if(isdigit(s1[i]))
{
s2[n] = s1[i];
n++;
}
}
s2[n+1] = '\0';
puts(s2);
return 0;
}
#include <string.h>
#include <ctype.h>
int main(void)
{
int i, n, len;
n = 0;
char s2[50];
char s1[] = "Hello World 123";
len = strlen(s1);
for(i = 0; i < len; i++)
{
if(isdigit(s1[i]))
{
s2[n] = s1[i];
n++;
}
}
s2[n+1] = '\0';
puts(s2);
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询