http://www.poluoluo.com/jzxy/201403/265005.html 首先要记住json_encode返回的是字符串, 而json_decode返回的是对象 判断数据不是JSON格式: .代码如下: function is_not_json($str){ return is ...
分类:
Web程序 时间:
2016-04-04 18:12:05
阅读次数:
123
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Have you thought about this? Here ...
分类:
编程语言 时间:
2016-04-04 17:59:27
阅读次数:
142
Given a list of numbers, return all possible permutations. Example For nums = [1,2,3], the permutations are: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3, ...
分类:
其他好文 时间:
2016-04-04 14:52:32
阅读次数:
90
Given n and k, return the k-th permutation sequence. Notice n will be between 1 and 9 inclusive. n will be between 1 and 9 inclusive. n will be betwee ...
分类:
其他好文 时间:
2016-04-04 14:29:20
阅读次数:
134
#include<stdio.h>
inthalf_search(intarr[],intfirst,intlast,intn)
{
intmid=0;
while(first<=last)
{
mid=(first+last)/2;
if(n<arr[mid])
{
last=mid-1;
}
elseif(n>arr[mid])
{
first=mid+1;
}
else
{
return1;
}
}
return-1;
}
intmain()
{
intarr[]={1,3..
分类:
其他好文 时间:
2016-04-04 13:24:22
阅读次数:
159
//求两个数平均值的方法:Avg=(ValueA&ValueB)+(ValueA^ValueB)>>1
#include<stdio.h>
intbit(intx,inty)
{
return(x&y)+((x^y)>>1);
}
intmain()
{
inta=0;
intb=0;
intret;
printf("请输入俩数:\n");
scanf("%d%d",&a,&b);
ret=bit(a,b);..
分类:
其他好文 时间:
2016-04-04 13:24:12
阅读次数:
156
一、JAVA的垃圾回收机制 垃圾回收机制是回收没有被变量所指向的对象。 垃圾回收机制由虚拟机执行,虚拟机会在比较空闲的时候进行垃圾回收,程序员没法干预。 但是程序员可以通过调用system.gc( )的方式加快垃圾回收的速度。 补充:return的使用 除了在有返回类型中返回值 还可以在void无返 ...
分类:
其他好文 时间:
2016-04-04 13:12:26
阅读次数:
129
die()停止程序运行,输出内容exit是停止程序运行,不输出内容return是返回值die是遇到错误才停止exit是直接停止,并且不运行后续代码,exit()可以显示内容。return就是纯粹的返回值了,但是也不会运行后续代码exit(0):正常运行程序并退出程序;exit(1):非正常运行导致退... ...
分类:
Web程序 时间:
2016-04-04 10:18:24
阅读次数:
172
#include<stdio.h>#include<stdlib.h>voidchaxun(a3){ intb; b=a3; printf("您的余额:%d\n",b);}intqukuan(inta3){ inta=0,b=0; printf("请输入要取的金额:\n"); scanf("%d",&a); b=a3-a; if(b<0) { printf("您的余额不足\n"); } else { printf("请拿好你..
分类:
编程语言 时间:
2016-04-04 06:56:12
阅读次数:
419
45%的概率友好致敬25%的概率转身离开20%的概率攻击10%的概率送礼intchoose(){float[]propArray={45%,25%,20%,10%}floattotal=0.0f;for(inti=0;i<propArray.length;i++){total+=propArray[i];}floatpropValue=Random.value*total;for(inti=0;i<propArray.length;i++){if(p..
分类:
编程语言 时间:
2016-04-04 06:51:57
阅读次数:
218