当前位置:网站首页>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 ;
边栏推荐
- 微服務鏈路風險分析
- Database tuning solution
- Implementation technology of recovery
- Cross end solutions to improve development efficiency
- Platform bus
- When the industrial Internet era is truly mature, we will look at the emergence of a series of new industrial giants
- Solutions for unexplained downtime of MySQL services
- Win11运行cmd提示“请求的操作需要提升”的解决方法
- 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
- POJ 3237 tree (tree chain splitting)
猜你喜欢
How can Bluetooth in notebook computer be used to connect headphones
The difference between MVVM and MVC
ESP32 hosted
Dbeaver executes multiple insert into error processing at the same time
Solutions for unexplained downtime of MySQL services
AD637 usage notes
[Yugong series] go teaching course in July 2022 004 go code Notes
[Yugong series] go teaching course 003-ide installation and basic use in July 2022
Cobaltstrike builds an intranet tunnel
What if win11 is missing a DLL file? Win11 system cannot find DLL file repair method
随机推荐
【愚公系列】2022年7月 Go教学课程 003-IDE的安装和基本使用
A substring with a length of three and different characters in the leetcode simple question
Search: Future Vision (moving sword)
Oracle advanced query
Installation of VMware Workstation
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
How to use tensorflow2 for cat and dog classification and recognition
Web3为互联网带来了哪些改变?
Reptile practice
Technology cloud report: how many hurdles does the computing power network need to cross?
Leetcode simple question check whether all characters appear the same number of times
U盘的文件无法删除文件怎么办?Win11无法删除U盘文件解决教程
Database recovery strategy
The difference between MVVM and MVC
[Yugong series] go teaching course 003-ide installation and basic use in July 2022
数据泄露怎么办?'华生·K'7招消灭安全威胁
Kubernetes Administrator certification (CKA) exam notes (IV)
IIC bus realizes client device
Interprocess communication in the "Chris Richardson microservice series" microservice architecture
Regular expressions and re Libraries