当前位置:网站首页>找数字
找数字
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;
}
边栏推荐
- Xcode abnormal pictures cause IPA packet size problems
- LVGL 8.2 keyboard
- LVGL 8.2 List
- Free, easy-to-use, powerful lightweight note taking software evaluation: drafts, apple memo, flomo, keep, flowus, agenda, sidenote, workflow
- 自动控制原理快速入门+理解
- 金额计算用 BigDecimal 就万无一失了?看看这五个坑吧~~
- [algorithm leetcode] interview question 04.03 Specific depth node linked list (Multilingual Implementation)
- leetcode:6110. The number of incremental paths in the grid graph [DFS + cache]
- C language personal address book management system
- No servers available for service: xxxx
猜你喜欢

Node mongodb installation

Guitar Pro 8win10最新版吉他学习 / 打谱 / 创作

Free, easy-to-use, powerful lightweight note taking software evaluation: drafts, apple memo, flomo, keep, flowus, agenda, sidenote, workflow

Combined with case: the usage of the lowest API (processfunction) in Flink framework

Data Lake (13): spark and iceberg integrate DDL operations

Redis publier et s'abonner

Pandora IOT development board learning (RT thread) - Experiment 3 button experiment (learning notes)

Preliminary exploration of flask: WSGI

Xcode abnormal pictures cause IPA packet size problems

Kubernets pod exists finalizers are always in terminating state
随机推荐
Yyds dry goods inventory # solve the real problem of famous enterprises: continuous maximum sum
(1) The standard of performance tuning and the correct posture for tuning - if you have performance problems, go to the heapdump performance community!
Leetcode 1200 minimum absolute difference [sort] The Path of leetcode for heroding
Helix swarm Chinese package is released, and perforce further improves the user experience in China
对话龙智高级咨询顾问、Atlassian认证专家叶燕秀:Atlassian产品进入后Server时代,中国用户应当何去何从?
Leetcode 1200 minimum absolute difference [sort] the way of leetcode in heroding
[information retrieval] link analysis
Ffmpeg Visual Studio development (IV): audio decoding
SAIC Maxus officially released its new brand "mifa", and its flagship product mifa 9 was officially unveiled!
Preliminary exploration of flask: WSGI
flutter 报错 No MediaQuery widget ancestor found.
numpy笔记
5g TV cannot become a competitive advantage, and video resources become the last weapon of China's Radio and television
智能客服赛道:网易七鱼、微洱科技打法迥异
C language small commodity management system
C language course design questions
ES6 modularization
[algorithm leetcode] interview question 04.03 Specific depth node linked list (Multilingual Implementation)
Is BigDecimal safe to calculate the amount? Look at these five pits~~
深度学习 网络正则化