当前位置:网站首页>找数字
找数字
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;
}
边栏推荐
- 自动控制原理快速入门+理解
- Introduction to asynchronous task capability of function calculation - task trigger de duplication
- LVLG 8.2 circular scrolling animation of a label
- On the implementation plan of MySQL explain
- [cloud native] how can I compete with this database?
- Yyds dry goods inventory # solve the real problem of famous enterprises: continuous maximum sum
- 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)
- Alcohol driving monitoring system based on stm32+ Huawei cloud IOT design
- 现代控制理论入门+理解
猜你喜欢

Helix swarm Chinese package is released, and perforce further improves the user experience in China

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

Five minutes of machine learning every day: how to use matrix to represent the sample data of multiple characteristic variables?

LVGL 8.2 text shadow

Scratch Castle Adventure Electronic Society graphical programming scratch grade examination level 3 true questions and answers analysis June 2022

5G电视难成竞争优势,视频资源成中国广电最后武器

Preliminary exploration of flask: WSGI

《opencv学习笔记》-- 线性滤波:方框滤波、均值滤波、高斯滤波

为什么国产手机用户换下一部手机时,都选择了iPhone?

深度学习 网络正则化
随机推荐
LVGL 8.2 Menu
Programmers exposed that they took private jobs: they took more than 30 orders in 10 months, with a net income of 400000
Pandora IOT development board learning (RT thread) - Experiment 3 button experiment (learning notes)
开发中常见问题总结
LVGL 8.2 List
如何配和弦
Free, easy-to-use, powerful lightweight note taking software evaluation: drafts, apple memo, flomo, keep, flowus, agenda, sidenote, workflow
PLC Analog input analog conversion FC s_ ITR (CoDeSys platform)
函数计算异步任务能力介绍 - 任务触发去重
Introduction to asynchronous task capability of function calculation - task trigger de duplication
LVGL 8.2 LED
Techsmith Camtasia Studio 2022.0.2屏幕录制软件
Test evaluation of software testing
Helix swarm Chinese package is released, and perforce further improves the user experience in China
UFO:微软学者提出视觉语言表征学习的统一Transformer,在多个多模态任务上达到SOTA性能!...
Leetcode 1200 minimum absolute difference [sort] the way of leetcode in heroding
C language programming
Is it safe to open an account online for stock speculation? Will you be cheated.
Detailed analysis of pytorch's automatic derivation mechanism, pytorch's core magic
C language personal address book management system