码迷,mamicode.com
首页 >  
搜索关键字:if then else    ( 23991个结果
一个小递归算法
publicstaticvoidmain(String[]args){ System.out.println("打印小于50的数,逆序"); printOne(2); } publicstaticvoidprintOne(intn){ //System.out.println(n); if(n<50) printOne(2*n); else{ //System.out.println(n); printTwo(n/2); } } ..
分类:其他好文   时间:2014-08-11 03:08:21    阅读次数:195
rwkj 1518
#includeint f(int a[],int low,int high,int x){ int mid; while (lowx) high=mid-1; else if(a[mid]int f(int a[],int low,int high,int x)...
分类:其他好文   时间:2014-08-10 12:39:50    阅读次数:361
hdu 1421 搬寝室 (dp)
思路分析:  dp[i][j] 表示选取到第 i 个   组成了 j 对的最优答案。 当然排序之后 选取相邻两个是更优的。 if(i==j*2) dp[i][j] = dp[i-2][j-1] + w[i]-w[i-2]^2.. else if( i> j*2 ) dp[i][j] = min (dp[i-2][j-1] + ...^2   ,    dp[i-1][j]).......
分类:其他好文   时间:2014-08-10 10:26:00    阅读次数:253
IT公司100题-12-求1+2+…+n
问题描述:求1+2+…+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字以及条件判断语句(A?B:C)。分析:利用类的静态变量实现:new一含有n个这种类的数组,那么该类的构造函数将会被调用n次。代码实现: 1 // 12.cc 2 #include 3 ....
分类:其他好文   时间:2014-08-09 21:26:49    阅读次数:242
【android】禁止Edittext弹出软键盘并且使光标正常显示
/** * 禁止Edittext弹出软件盘,光标依然正常显示。 */ public void disableShowSoftInput() { if (android.os.Build.VERSION.SDK_INT <= 10) { editText.setInputType(InputType.TYPE_NULL); } else { ...
分类:移动开发   时间:2014-08-09 18:52:58    阅读次数:246
Java 语法 索引 ----- 条件语句(If Else,Switch)
if (x 1) System.out.print(x + " > 1");else System.out.print(x + " == 1");Switchswitch (y){ case 0: System.out.print(y + " is 0"); break; case 1: Syste...
分类:编程语言   时间:2014-08-09 02:35:12    阅读次数:192
POJ 3280 Cheapest Palindrome DP题解
看到Palindrome的题目,首先想到的应该是中心问题,然后从中心出发,思考如何解决。 DP问题一般是从更加小的问题转化到更加大的问题,然后是从地往上 bottom up地计算答案的。 能得出状态转移方程就好办了,本题的状态转移方程是: if (cowID[i] == cow{j]) tbl[id][i] = tbl[id][i+1];//相等的时候无需改动 else tbl[id][i...
分类:其他好文   时间:2014-08-09 00:14:16    阅读次数:344
PHP文件操作:遍历文件目录
1 该目录下的文件(升序排列):'; 12 print_r($files_asc); 13 echo '该目录下的文件(降序排序):'; 14 print_r($files_desc); 15 } 16 else{ 17 ...
分类:Web程序   时间:2014-08-08 23:47:06    阅读次数:405
485-A*B Problem-nyoj20140808
#include int main(){ int T; scanf("%d",&T); while(T--) { int sum; long long a,b; scanf("%lld %lld",&a,&b); if(a==0||b==0) { sum=0; } else { sum=(a%9)....
分类:其他好文   时间:2014-08-08 21:15:26    阅读次数:252
c++ 宏定义和typedef初步认识
宏: #define MAX(x,y) (((x) init()) \ { \ pRet->autorelease(); \ return pRet; \ } \ else \ { \ delete pRet; \ p...
分类:编程语言   时间:2014-08-08 20:52:56    阅读次数:238
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!