当前位置:网站首页>找数字
找数字
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;
}
边栏推荐
- Leetcode 1200 minimum absolute difference [sort] the way of leetcode in heroding
- Ali was laid off employees, looking for a job n day, headhunters came bad news
- 自动控制原理快速入门+理解
- LVGL 8.2 text shadow
- Stm32f1 and stm32subeide programming example -max7219 drives 8-bit 7-segment nixie tube (based on GPIO)
- An overview of 2D human posture estimation
- flutter 报错 No MediaQuery widget ancestor found.
- LVGL 8.2 Menu
- Wt588f02b-8s (c006_03) single chip voice IC scheme enables smart doorbell design to reduce cost and increase efficiency
- First experience of ViewModel
猜你喜欢

智能客服赛道:网易七鱼、微洱科技打法迥异

Digi restarts XBee Pro S2C production. Some differences need to be noted

UFO: Microsoft scholars have proposed a unified transformer for visual language representation learning to achieve SOTA performance on multiple multimodal tasks

Alcohol driving monitoring system based on stm32+ Huawei cloud IOT design
![Leetcode 1200 minimum absolute difference [sort] The Path of leetcode for heroding](/img/4a/6763e3fbdeaf9de673fbe8eaf96858.png)
Leetcode 1200 minimum absolute difference [sort] The Path of leetcode for heroding

Detailed analysis of pytorch's automatic derivation mechanism, pytorch's core magic

近一亿美元失窃,Horizon跨链桥被攻击事件分析

Query optimizer for SQL optimization

Codeforce:c. sum of substrings

Redis publish and subscribe
随机推荐
Data Lake (13): spark and iceberg integrate DDL operations
Introduction to modern control theory + understanding
深度学习7 Transformer系列实例分割Mask2Former
remount of the / superblock failed: Permission denied
LVGL 8.2 List
Explain of SQL optimization
LVGL 8.2 keyboard
Quick introduction to automatic control principle + understanding
LVGL 8.2 Line
Luo Gu - some interesting questions 2
leetcode:6109. Number of people who know the secret [definition of DP]
如何搭建一支搞垮公司的技术团队?
都在说DevOps,你真正了解它吗?
C language book rental management system
Is it safe to open an account online for stock speculation? Will you be cheated.
Ranking list of databases in July: mongodb and Oracle scores fell the most
自动控制原理快速入门+理解
Redis 发布和订阅
Solutions to the problems of miui12.5 red rice k20pro using Au or povo2
[information retrieval] link analysis