zoukankan      html  css  js  c++  java
  • usort 函数

    function getNameFromNumber($num){
    // Used to figure out what the Excel column name would be for a given 0-indexed array of data
    $numeric = ($num-1)%26;
    $letter = chr(65+$numeric);
    $num2 = intval(($num-1) / 26);
    if ( $num2 > 0 ) {
    return getNameFromNumber($num2) . $letter;
    } else {
    return $letter;
    }
    }

    function GetDevicesbyOwner(){
    global $dbh;

    $this->MakeSafe();

    $sql="SELECT *, (SELECT b.DataCenterID FROM fac_Device a, fac_Cabinet b
    WHERE a.Cabinet=b.CabinetID AND a.DeviceID=search.DeviceID ORDER BY
    b.DataCenterID, a.Label) DataCenterID FROM fac_Device search WHERE
    Status<>'Disposed' AND Owner=$this->Owner ORDER BY Label;";

    $deviceList=array();
    foreach($dbh->query($sql) as $deviceRow){
    $deviceList[$deviceRow["DeviceID"]]=Device::RowToObject($deviceRow);
    }

    return $deviceList;
    }
    function ticksToTime($ticks) {
    $seconds=floor($ticks/100);
    // $date = new DateTime('2000-01-01');
    $dtF=new DateTime("@0");
    $dtT=new DateTime("@$seconds");
    $a=$dtF->diff($dtT)->format('%a'); //%a返回总天数
    $h=$dtF->diff($dtT)->format('%h'); //%h 小时 0--23
    $i=$dtF->diff($dtT)->format('%i'); //%i 分钟 0-59
    $s=$dtF->diff($dtT)->format('%s'); // %s 秒 0-59
    if($a>0){
    return $dtF->diff($dtT)->format('%a days, %h hours, %i minutes and %s seconds');
    }else if($h>0){
    return $dtF->diff($dtT)->format('%h hours, %i minutes and %s seconds');
    }else if($i>0){
    return $dtF->diff($dtT)->format(' %i minutes and %s seconds');
    }else{
    return $dtF->diff($dtT)->format('%s seconds');
    }
    }
     
     
  • 相关阅读:
    ACM ICPC 2008–2009 NEERC MSC A, B, C, G, L
    POJ 1088 滑雪 DP
    UVA 11584 最短回文串划分 DP
    POJ 2531 Network Saboteur DFS+剪枝
    UVa 10739 String to Palindrome 字符串dp
    UVa 11151 Longest Palindrome 字符串dp
    UVa 10154 Weights and Measures dp 降维
    UVa 10271 Chopsticks dp
    UVa 10617 Again Palindrome 字符串dp
    UVa 10651 Pebble Solitaire 状态压缩 dp
  • 原文地址:https://www.cnblogs.com/hehexu/p/8600690.html
Copyright © 2011-2022 走看看