当前位置:网站首页>找数字
找数字
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;
}
边栏推荐
- On the implementation plan of MySQL explain
- LVGL 8.2 Line
- Detailed explanation of visual studio debugging methods
- Explain of SQL optimization
- Alcohol driving monitoring system based on stm32+ Huawei cloud IOT design
- Combined with case: the usage of the lowest API (processfunction) in Flink framework
- A collection of classic papers on convolutional neural networks (deep learning classification)
- Stm32f1 and stm32subeide programming example -max7219 drives 8-bit 7-segment nixie tube (based on GPIO)
- Introduction to modern control theory + understanding
- 关于FPGA底层资源的细节问题
猜你喜欢
(1) The standard of performance tuning and the correct posture for tuning - if you have performance problems, go to the heapdump performance community!
An overview of 2D human posture estimation
Query optimizer for SQL optimization
LVGL 8.2 Line wrap, recoloring and scrolling
Redis publish and subscribe
Docker compose public network deployment redis sentinel mode
Free, easy-to-use, powerful lightweight note taking software evaluation: drafts, apple memo, flomo, keep, flowus, agenda, sidenote, workflow
Pandora IOT development board learning (RT thread) - Experiment 3 button experiment (learning notes)
Luo Gu - some interesting questions 2
如何配和弦
随机推荐
深度学习 神经网络案例(手写数字识别)
Solutions to the problems of miui12.5 red rice k20pro using Au or povo2
LVGL 8.2 keyboard
Halo effect - who says that those with light on their heads are heroes
Introduction to modern control theory + understanding
Industrial Internet has greater development potential and more industry scenarios
Gin integrated Alipay payment
Leecode learning notes - Joseph problem
对话龙智高级咨询顾问、Atlassian认证专家叶燕秀:Atlassian产品进入后Server时代,中国用户应当何去何从?
内存管理总结
Redis publier et s'abonner
Luo Gu - some interesting questions 2
程序员自曝接私活:10个月时间接了30多个单子,纯收入40万
Programmers exposed that they took private jobs: they took more than 30 orders in 10 months, with a net income of 400000
03-存储系统
Docker compose public network deployment redis sentinel mode
Sqlserver functions, creation and use of stored procedures
Leetcode 1200 minimum absolute difference [sort] The Path of leetcode for heroding
Comment configurer un accord
【C语言】指针笔试题