一:Reverse Integer
题目:
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
链接:https://leetcode.com/problems/reverse-integer/
分析:这题通过不断取余将余数存放在一个vecto...
分类:
其他好文 时间:
2015-04-05 14:40:31
阅读次数:
161
??
问题描述:
Implement
atoi to convert a string to an integer.
Hint: Carefullyconsider all possible input
cases. If you want a challenge, please do not seebelow and ask yourself what are the...
分类:
其他好文 时间:
2015-04-04 09:19:09
阅读次数:
162
myitoa
#include
#include
void resver(char *s)//反转字符串
{
int len = strlen(s);
//printf("len=%d\n",len);
int i = 0;
char tmp = 0;
for (; i<len/2; i++)
{
tmp = s[i];...
分类:
其他好文 时间:
2015-04-02 22:38:49
阅读次数:
260
http://c.biancheng.net/cpp/html/792.htmlC语言提供了几个标准库函数,可以将任意类型(整型、长整型、浮点型等)的数字转换为字符串。以下是用itoa()函数将整数转换为字符串的一个例子:# include # include void main (void){in...
分类:
编程语言 时间:
2015-04-02 18:20:54
阅读次数:
184
/*编写一个函数,将一个数字字符串转换成该字符串对应的数字(包括正整数、负整数)
例如:"12" 返回12
"-123" 返回-123
函数原型:int my_atoi(char *str)*/
#include
int my_atoi(char const *str)
{
int sum = 0;
int p;
int n = 0;
if( *str == '-' )
{
...
分类:
编程语言 时间:
2015-04-02 13:25:57
阅读次数:
143
/*
编写一个函数,将一个数字字符串转换成该字符串对应的数字(包括正整数、负整数)例如:“12“ 返回12 “-123“ 返回-123
函数原型:int my_atoi(char *str)
{}
*/
#include
int my_atoi(char *str)
{
int n=0;
int sum=0;
if (*str=='-')
{
str++;
n=1;
}
...
分类:
编程语言 时间:
2015-04-02 13:25:35
阅读次数:
148
在python 2.7 后,不推荐使用 optparse, 而推荐使用 argparse.
其它的不多说,简单的分析下我遇到的问题:我是想用 argparse 来解析不定长的命令行参数
例如:
import argparse
import sys
parser = argparse.ArgumentParser(description='test parsing arguments')...
分类:
编程语言 时间:
2015-04-01 23:47:28
阅读次数:
206
把所给的字符串按照规定转化成相应的数字。要考虑溢出的情况,含有非法字符的情况,数字前有空格的情况。但是还是比较简单的。public class Solution { public int atoi(String str) { StringBuilder s = ...
分类:
其他好文 时间:
2015-04-01 19:53:45
阅读次数:
102
执行powershell脚本有两种方式:1、通过命令行参数启动脚本C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -version 2.0 -noexit -command ". 'C:\Users\Administrator\De...
分类:
系统相关 时间:
2015-04-01 16:56:31
阅读次数:
134
LeetCode #String to Integer (atoi)#
自己写一个atoi. 其实之前都没怎么调用过这个库函数. 具体性能也不怎么知道.
自己写的时候感觉有个版本比题目要求还好,但是不能被接受, 于是就改改改
话说AC的感觉真爽...
我尽量把代码写的紧凑...
"""
Programmer : EOF
Date : 2...
分类:
其他好文 时间:
2015-04-01 15:26:17
阅读次数:
141