algo prac
文章平均质量分 73
靳皓屹工作站
一个喜欢折腾的房奴
展开
-
C和指针编程练习---6.18.1
/**********************************************/ /******find whether two strings same thing ****/ /**********************************************/ #include char *find_char(char *source,char *chars)原创 2016-08-28 12:03:10 · 491 阅读 · 0 评论 -
linux assemble environment
1、下载nasm安装包 #wget http://www.nasm.us/pub/nasm/releasebuilds/2.11.08/nasm-2.11.08.tar.gz 2、解压安装nasm #tar -xzvf nasm-2.11.08.tar.gz #cd nasm-2.11.08 #./configure #make #make install 3、编写hello.as转载 2016-12-10 22:11:54 · 363 阅读 · 0 评论 -
3th Validate Binary Search Tree
用递归做得,遇到的坑是用cygwin带的gcc编译,总是遇到各种莫名其妙的段溢出。。。珍爱生命,远离cygwin。。 #include "stdio.h" #include "stdlib.h" #include "string.h" //Definition for a binary tree node. struct TreeNode { char val;原创 2017-09-11 00:40:31 · 314 阅读 · 0 评论 -
1th 整数 罗马数 转换
代码很简单,采用查表法做。所以直接贴出来吧。#include #include #include "string.h" char lut_1[10][8] = {"I","II","III","IV","V","VI","VII","VIII","IX"}; char lut_10[10][8] = {"X","XX","XXX","XL","L","LX","LXX","LXXX","XC原创 2017-09-03 00:25:48 · 322 阅读 · 0 评论 -
2th roma int
这个仍旧使用查表法,比较简单,直接上代码: #include #include #include "string.h" #include "math.h" char lut_1[10][8] = {"I","II","III","IV","V","VI","VII","VIII","IX"}; char lut_10[10][8] = {"X","XX","XXX","XL","L","L原创 2017-09-03 11:41:11 · 528 阅读 · 0 评论 -
4th Largest Rectangle in Histogram
这个题目十分简单,直接循环就可求出来。 #include #include int calc_rect(int cof1 , int cof2) { if(cof1 <= cof2 ) return 2*cof1; else return 2*cof2; } int process(int *buf , int lens) { int k=0,f=k+1 , max_rec原创 2017-10-06 22:21:23 · 215 阅读 · 0 评论 -
6th Maximal Rectangle
这里仍旧使用暴力求解法,求出矩阵中的最大的矩形面积。 /* calc max rect in a matrix eg: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 res: 6 */ int buf_all[4][5] = {1 ,1 ,1 ,1 ,1 , 1 ,1 ,1 ,1 ,1 , 1 ,1 ,1 ,1 ,1 ,原创 2017-10-07 11:10:38 · 232 阅读 · 0 评论 -
5th IP address restore
这次欠债比较多,所以,这次的代码风格很差。方法是最暴力的暴力求解法。 //ip restore //if input is 19216811 //out put should be 192.168.1.1 or 19.216.8.11 or some_str available else #include #include #include #define LOG_FLAG 1 /*原创 2017-10-06 13:12:00 · 254 阅读 · 0 评论