当前位置:网站首页>输入字符串,内有数字和非字符数组,例如A123x456将其中连续的数字作为一个整数,依次存放到一个数组中,如123放到a[0],456放到a[1],并输出a这些数
输入字符串,内有数字和非字符数组,例如A123x456将其中连续的数字作为一个整数,依次存放到一个数组中,如123放到a[0],456放到a[1],并输出a这些数
2022-07-28 11:40:00 【yi_tianchou】
#include "string.h"
#include "math.h"
int isdigit(char c)
{
if(c>47 && c<58)
{
return 1;
}
return 0;
}
char *s_gets(char *st,int size);
int main()
{
char str[30],str1[10][10],*end;
int t=0,m=0,i,digit_num=0;long a[9];
printf("请输入一个字符串:");
s_gets(str,30);
for(i=0;i<strlen(str);i++)
{
if(isdigit(str[i]))
{
str1[m][t]=str[i];
t++;
digit_num++;
}
else
{
if(t!=0)
{
str1[m][t]='\0';
// a[m]=strtol(str1[m],&end,10);
t=0;
m++;
}
}
printf("%c",str[i]);
}
printf("共有%d位数字",digit_num);
for(i=0;i<=m;i++)
printf(" %s",str1[i]);
return 0;
}
char *s_gets(char *st,int size)
{
char *ret_val;
int i=0;
ret_val=fgets(st,size,stdin);
if(ret_val)
{
while(st[i]!='\0'&&st[i]!='\n')
i++;
if(st[i]='\n')
st[i]='\0';
else
while(getchar()!='\n')
continue;
}
return ret_val;
}
边栏推荐
- Knowledge points of MySQL (13)
- Analysys analysis: focus on users, improve the user experience of mobile banking, and help the growth of user value
- PHP ⽉ the simplest way to add and subtract ⽅
- How to build knowledge management system in enterprises and institutions
- Unity加载Glb模型
- 聚变云原生,赋能新里程 | 2022 开放原子全球开源峰会云原生分论坛圆满召开
- Brief discussion on open source OS distribution
- SQL injection less23 (filter comment)
- Solve the PHP prompt warning: division by zero in error
- What if the instruction set umi2 is missing? PTK installation cannot be carried out
猜你喜欢

Come to tdengine Developer Conference and have an insight into the future trend of data technology development

新东方单季营收5.24亿美元同比降56.8% 学习中心减少925间

洪九果品通过聆讯:5个月经营利润9亿 阿里与中国农垦是股东

VS1003调试例程

leetcode:数组

DIY system home page, your personalized needs PRO system to meet!

Aopmai biological has passed the registration: the half year revenue is 147million, and Guoshou Chengda and Dachen are shareholders

Developing NES game (cc65) 07 and controller with C language

分布式定时器

MarkDown简明语法手册
随机推荐
Great! Jd.com developed the highly available website construction technology PDF recommended by the first brother. Prepare the water and chew it slowly
PHP date time application: add or subtract the number of days of a specific date
[nuxt 3] (XII) project directory structure 3
AVL tree (balanced search tree)
用C语言开发NES游戏(CC65)10、游戏循环
Holes in [apue] files
C for循环内定义int i变量出现的重定义问题
SQL injection LESS18 (header injection + error injection)
Hongjiu fruit passed the hearing: five month operating profit of 900million Ali and China agricultural reclamation are shareholders
What SaaS architecture design does a software architect need to know?
开源社区三十年 | 2022 开放原子全球开源峰会开源社区三十年专题活动圆满召开
Distributed timer
leetcode:704二分查找
Developing NES game (cc65) 07 and controller with C language
[apue] 文件中的空洞
Analysys analysis: focus on users, improve the user experience of mobile banking, and help the growth of user value
用C语言开发NES游戏(CC65)02、什么是v-blank?
软件架构师必需要了解的 saas 架构设计?
GMT installation and use
VS1003调试例程