当前位置:网站首页>Character conversion PTA
Character conversion PTA
2022-07-05 22:14:00 【Sophomore to major】
This problem requires the extraction of all numeric characters in a string ('0'……'9'), Convert it to an integer output .
Input format :
The input gives no more than 80 Character string ending with carriage return .
Output format :
Output the converted integer on one line . Ensure that the output does not exceed the long integer range .
sample input :
#include <stdio.h>
int main(){
char ch[81];
int i=0,sum=0;
while((ch[i]=getchar())!='\n'){
if(ch[i]>='0'&&ch[i]<='9'){
sum=sum*10+ch[i]-'0';
}
i++;
}
printf("%d",sum);
return 0;
}
free82jeep5
sample output :
825
Ideas : Use it directly first putchar(), trouble , It's much simpler after changing to numerical value ;
边栏推荐
- AD637 usage notes
- Leetcode simple question ring and rod
- NET中小型企业项目开发框架系列(一个)
- 微服务链路风险分析
- ESP32 hosted
- Oracle hint understanding
- What if win11 is missing a DLL file? Win11 system cannot find DLL file repair method
- A long's perception
- FBO and RBO disappeared in webgpu
- Analyse des risques liés aux liaisons de microservices
猜你喜欢
The simple problem of leetcode is to split a string into several groups of length K
How to view Apache log4j 2 remote code execution vulnerability?
Database tuning solution
Two stage locking protocol for concurrency control
Business learning of mall order module
Shell script, awk condition judgment and logic comparison &||
Bitbucket installation configuration
A substring with a length of three and different characters in the leetcode simple question
boundary IoU 的计算方式
Type of fault
随机推荐
笔记本电脑蓝牙怎么用来连接耳机
Net small and medium-sized enterprise project development framework series (one)
MySQL连接断开报错MySQLdb._exceptions.OperationalError 4031, The client was disconnected by the server
AD637使用笔记
Codeforces 12D Ball 树形阵列模拟3排序元素
极狐公司官方澄清声明
Stored procedures and stored functions
Web3为互联网带来了哪些改变?
Getting started with microservices (resttemplate, Eureka, Nacos, feign, gateway)
A long's perception
1.3 years of work experience, double non naked resignation agency face-to-face experience [already employed]
从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
ICMP introduction
A number of ventilator giants' products have been recalled recently, and the ventilator market is still in incremental competition
Technology cloud report won the special contribution award for the 10th anniversary of 2013-2022 of the "cloud Ding Award" of the global cloud computing conference
Shell script, awk uses if, for process control
【愚公系列】2022年7月 Go教学课程 004-Go代码注释
boundary IoU 的计算方式
Ad637 notes d'utilisation
HDU 4391 paint the wall segment tree (water