跳到主要內容

發表文章

目前顯示的是 4月, 2017的文章

Multiple without multication or addition operator

Given two binary strings, return their sum (also a binary string). For example, a = "1101" // 13 b = "1000" // 8 Return “1101000”. // 104 Solution: implement Binary add to perform multication static int MultipleWithoutOperator(int num, int multiplier) { StringBuilder sb = new StringBuilder(); string binary = Convert.ToString(num, 2); string binaryMultiplier = Convert.ToString(multiplier, 2); string temp = ""; for (int i = binaryMultiplier.Length-1, j=0;i >= 0;i--,j++){ if (binaryMultiplier[i]=='1') { if (string.IsNullOrEmpty(temp)) { temp = binary.PadRight(binary.Length + j, '0'); } else { temp = BinaryAdd(temp, binary.PadRight(binary.Length + j, '0')); } } } return Convert.ToInt32(temp, 2); } static string BinaryAdd(string a, string b) { int carryover = 0; Stri

I found a online free GeoNames lookup service

main page: http://www.geonames.org/ the api overview: http://www.geonames.org/export/ws-overview.html api templte: http://api.geonames.org/method?params=query&username=yourname the jeoquery.js file for jquery using http://tompi.github.io/jeoquery/jeoquery.js var methods = { astergdem: {params: ['lat', 'lng'] }, children: {params: ['geonameId', 'maxRows'] }, cities: {params: ['north', 'south', 'east', 'west', 'lang'] }, countryCode: {params: ['lat', 'lng', 'type', 'lang', 'radius'] }, countryInfo: {params: ['country', 'lang'] }, countrySubdivision: {params: ['lat', 'lng', 'level', 'lang', 'radius'] }, earthquakes: {params: ['north', 'south', 'east', 'west', 'date', 'maxRows', 'minMagnitude'] }, findNearby: {params: ['lat', 'lng', '