当前位置:网站首页>找数字
找数字
2022-07-04 13:32:00 【Zaltana】
输入一个字符串(包含26个英文字母大小写及.空格,不含其他字符),把其中连续的数字作为一个整数,依次存放到- -个数组中,输出这些整数的和。
格式
输入格式:输入字符串
输出格式:输出整型
样例
输入: a123.456 jmk32kk
输出: 611
#include<bits/stdc++.h>
using namespace std;
int main( )
{
char a[100];
cin.getline(a,100);
int lens = strlen(a);
int sum=0, num=0;
for (int i=0; i<=lens; i++) {
int loc = a[i] - '0';
if (loc>=0 && loc<=9) {
num = num*10 + loc;
}
else {
sum += num;
num = 0;
}
}
printf("%d", sum);
return 0;
}
边栏推荐
- Graduation season - personal summary
- LVGL 8.2 List
- Kubernets pod exists finalizers are always in terminating state
- Transplant tinyplay for imx6q development board QT system
- C language small commodity management system
- remount of the / superblock failed: Permission denied
- 开发中常见问题总结
- Ali was laid off employees, looking for a job n day, headhunters came bad news
- 【C语言】指针笔试题
- LVLG 8.2 circular scrolling animation of a label
猜你喜欢
微博、虎牙挺进兴趣社区:同行不同路
03 storage system
leetcode:6110. The number of incremental paths in the grid graph [DFS + cache]
Flutter reports an error no mediaquery widget ancestor found
92. (cesium chapter) cesium building layering
Query optimizer for SQL optimization
IO流:节点流和处理流详细归纳。
Digi restarts XBee Pro S2C production. Some differences need to be noted
An overview of 2D human posture estimation
Ranking list of databases in July: mongodb and Oracle scores fell the most
随机推荐
Comment configurer un accord
LVGL 8.2 Menu
Is BigDecimal safe to calculate the amount? Look at these five pits~~
产品好不好,谁说了算?Sonar提出分析的性能指标,帮助您轻松判断产品性能及表现
Ffprobe common commands
微博、虎牙挺进兴趣社区:同行不同路
How to match chords
LVGL 8.2 text shadow
How to handle exceptions in multithreading?
对话龙智高级咨询顾问、Atlassian认证专家叶燕秀:Atlassian产品进入后Server时代,中国用户应当何去何从?
【C语言】指针笔试题
A keepalived high availability accident made me learn it again
A collection of classic papers on convolutional neural networks (deep learning classification)
Free, easy-to-use, powerful lightweight note taking software evaluation: drafts, apple memo, flomo, keep, flowus, agenda, sidenote, workflow
深度学习 神经网络案例(手写数字识别)
现代控制理论入门+理解
Luo Gu - some interesting questions
Classify boost libraries by function
Programmer turns direction
信号处理之一阶RC低通滤波器宏指令实现(繁易触摸屏)