当前位置:网站首页>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 :
825Ideas : Use it directly first putchar(), trouble , It's much simpler after changing to numerical value ;
边栏推荐
- Type of fault
- 从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
- Shell script, awk condition judgment and logic comparison &||
- Three "factions" in the metauniverse
- CRM creates its own custom report based on fetch
- Bitbucket installation configuration
- 阿龙的感悟
- ICMP introduction
- Recovery technology with checkpoints
- How can Bluetooth in notebook computer be used to connect headphones
猜你喜欢

Stored procedures and stored functions

Talking about MySQL index

【愚公系列】2022年7月 Go教学课程 004-Go代码注释

The Blue Bridge Cup web application development simulation competition is open for the first time! Contestants fast forward!

K210学习笔记(四) K210同时运行多个模型

CA certificate trampled pit

Win11运行cmd提示“请求的操作需要提升”的解决方法

MySQL disconnection reports an error MySQL ldb_ exceptions. OperationalError 4031, The client was disconnected by the server

微服务入门(RestTemplate、Eureka、Nacos、Feign、Gateway)

IIC bus realizes client device
随机推荐
每日刷题记录 (十四)
Code bug correction, char is converted to int high-order symbol extension, resulting in changes in positivity and negativity and values. Int num = (int) (unsigned int) a, which will occur in older com
Concurrency control of performance tuning methodology
Text组件新增内容通过tag_config设置前景色、背景色
How can Bluetooth in notebook computer be used to connect headphones
让开发效率提升的跨端方案
Recovery technology with checkpoints
FBO and RBO disappeared in webgpu
了解 Android Kotlin 中 DataStore 的基本概念以及为什么应该停止在 Android 中使用 SharedPreferences
AD637使用筆記
Oracle triggers
ICMP 介绍
Pl/sql basic syntax
Summary of El and JSTL precautions
boundary IoU 的计算方式
Serializability of concurrent scheduling
装饰器学习01
Alternating merging strings of leetcode simple questions
Shell script, awk condition judgment and logic comparison &||
Kubernetes Administrator certification (CKA) exam notes (IV)