当前位置:网站首页>1-72 convert string to decimal integer
1-72 convert string to decimal integer
2022-06-13 04:00:00 【Python's path to becoming a God】

my
Code
#include <stdio.h>
#include <stdlib.h>
int main() {
char c;
int len = 0, flag = 0, a[8] = {0};
long int ans = 0;
while ((c = getchar()) != '#') {
if (c == '-')
flag = 1;
if (c >= '0' && c <= '9') {
a[len++] = c - '0';
break;
}
if (c >= 'a' && c <= 'f') {
a[len++] = c - 'a' + 10;
break;
}
if (c >= 'A' && c <= 'F') {
a[len++] = c - 'A' + 10;
break;
}
}
if (c != '#')
while ((c = getchar()) != '#') {
if (c >= '0' && c <= '9')
a[len++] = c - '0';
if (c >= 'a' && c <= 'f')
a[len++] = c - 'a' + 10;
if (c >= 'A' && c <= 'F')
a[len++] = c - 'A' + 10;
}
for (int i = len - 1, k = 1; i >= 0; --i, k *= 16)
ans += a[i] * k;
if (flag)
ans *= -1;
printf("%ld", ans);
return 0;
}边栏推荐
- Billions of data to determine whether the element exists
- 单片机:PCF8591硬件接口
- 【 développement d'essais 】 sélénium d'essais automatisés (Ⅲ) - - analyse du cadre unitest
- Flex layout
- Common array methods in JS (map, filter, foreach, reduce)
- 单片机:I2C通信协议讲解
- Time complexity
- 谈谈激光雷达的波长
- Detailed explanation of MySQL storage process
- 单片机:NEC 协议红外遥控器
猜你喜欢

Principle, composition and functions of sensors of Dajiang UAV flight control system

单片机:A/D 和 D/A 的基本概念

【MySQL】索引与事务

Real time requirements for 5g China Unicom repeater network management protocol

【测试开发】自动化测试selenium(二)——webdriver常用的API

不卷了!团队又一位成员离职了。。

Unity shader learning 004 shader debugging platform difference third-party debugging tools

ET框架-22 创建ServerInfo实体及事件

Time complexity
![[test development] basic concepts related to testing](/img/51/cdc1d2da0480cae3b6a71110e4efb4.png)
[test development] basic concepts related to testing
随机推荐
[test development] use case
Lambda终结操作查找与匹配allMatch
单片机:A/D(模数转换)的主要指标
十億數據量 判斷元素是否存在
Interpretation of mobile phone private charging protocol
ROS话题与节点
Single chip microcomputer: basic concepts of a/d and d/a
Lambda end operation find and match findfirst
单片机:Modbus 多机通信程序设计
Alibaba cloud keep on record
不卷了!团队又一位成员离职了。。
Express 100
Principle and control program of single chip microcomputer serial port communication
[test development] fundamentals of software testing
[test development] automated test selenium (II) -- common APIs for webdriver
Tencent cloud instant messaging IM
单片机外设介绍:温度传感器 DS18B20
Single chip microcomputer: infrared remote control communication principle
5G China unicom AP:B SMS ASCII 转码要求
Real time question answering of single chip microcomputer / embedded system