Beispiel #1
0
 /**
  * Main program.
  *
  * @param array $args Command-line arguments.
  * @return integer Zero on success; non-zero on failure.
  */
 public static function main($args)
 {
     printf("Application program number 1. (calculator)\n");
     $status = 0;
     Algorithms::calculator(STDIN, STDOUT);
     return $status;
 }
Beispiel #2
0
 /**
  * Main program.
  *
  * @param array $args Command-line arguments.
  * @return integer Zero on success; non-zero on failure.
  */
 public static function main($args)
 {
     printf("Application program number 5. (word counter)\n");
     $status = 0;
     Algorithms::wordCounter(STDIN, STDOUT);
     return $status;
 }
Beispiel #3
0
 /**
  * Main program.
  *
  * @param array $args Command-line arguments.
  * @return integer Zero on success; non-zero on failure.
  */
 public static function main($args)
 {
     printf("Application program number 9. (equivalence classes)\n");
     $status = 0;
     Algorithms::equivalenceClasses(STDIN, STDOUT);
     return $status;
 }
Beispiel #4
0
 /**
  * Main program.
  *
  * @param array $args Command-line arguments.
  * @return integer Zero on success; non-zero on failure.
  */
 public static function main($args)
 {
     printf("Application program number 7. (translator)\n");
     $status = 0;
     $dictionary = fopen('dict.txt', 'r');
     Algorithms::translate($dictionary, STDIN, STDOUT);
     fclose($dictionary);
     return $status;
 }
Beispiel #5
0
 /**
  * Main program.
  *
  * @param array $args Command-line arguments.
  * @return integer Zero on success; non-zero on failure.
  */
 public static function main($args)
 {
     $status = 0;
     printf("Application program number 2.\n");
     printf("Should be: dbfaceg.\n");
     $tree = self::buildTree(ord('a'), ord('g'));
     Algorithms::breadthFirstTraversal($tree);
     return $status;
 }
Beispiel #6
0
/**
 * @return true if this currency is a SHA256 currency and measured in MH/s rather than KH/s
 */
function is_hashrate_mhash($cur)
{
    if (in_array($cur, Currencies::getHashableCurrencies())) {
        $instance = Currencies::getInstance($cur);
        $algorithm = $instance->getAlgorithm();
        $algorithm_instance = Algorithms::getInstance($algorithm);
        return $algorithm_instance->getDivisor() >= 1000000.0;
    }
    return false;
}
 public function actionEdit($id)
 {
     $algorithm = Algorithms::model()->findByPk($id);
     if (isset($_REQUEST['Algorithms'])) {
         $algorithm->steps = $_REQUEST['Algorithms']['steps'];
         $algorithm->title = $_REQUEST['Algorithms']['title'];
         if (isset($_REQUEST['Algorithms']['Tracks'])) {
             $algorithm->setRelationRecords("Tracks", $_REQUEST['Algorithms']['Tracks']);
         }
         $algorithm->description = $_REQUEST['Algorithms']['description'];
         if ($algorithm->save()) {
             Yii::app()->notify->add("Обновлено", "success");
         }
     }
     $this->render('edit', array("algorithm" => $algorithm));
 }
Beispiel #8
0
 /**
  * Main program.
  *
  * @param array $args Command-line arguments.
  * @return integer Zero on success; non-zero on failure.
  */
 public static function main($args)
 {
     printf("Application program number 11.\n");
     $status = 0;
     $g = new GraphAsMatrix(32);
     Application11::weightedGraphTest($g);
     $g = new GraphAsLists(32);
     Application11::weightedGraphTest($g);
     $g = new DigraphAsMatrix(32);
     Application11::weightedDigraphTest($g);
     $g = new DigraphAsLists(32);
     Application11::weightedDigraphTest($g);
     printf("Critical path analysis.\n");
     $g = new DigraphAsMatrix(10);
     for ($v = 0; $v < 10; ++$v) {
         $g->addVertex($v);
     }
     $g->addEdge(0, 1, box(3));
     $g->addEdge(1, 2, box(1));
     $g->addEdge(1, 3, box(4));
     $g->addEdge(2, 4, box(0));
     $g->addEdge(3, 4, box(0));
     $g->addEdge(4, 5, box(1));
     $g->addEdge(5, 6, box(9));
     $g->addEdge(5, 7, box(5));
     $g->addEdge(6, 8, box(0));
     $g->addEdge(7, 8, box(0));
     $g->addEdge(8, 9, box(2));
     printf("%s\n", str($g));
     $g2 = Algorithms::criticalPathAnalysis($g);
     printf("%s\n", str($g2));
     return $status;
 }
Beispiel #9
0
	</div>   <!-- /.col-md-8 -->



</div> <!-- /.row -->
 
	<br>Презентации <br>

	<?php 
echo $form->dropDownList($track, 'Docs', CHtml::listData(Docs::model()->findAll(), 'id', 'title'), array("multiple" => true));
?>
	
	<br>Алгоритмы<br>

	<?php 
echo $form->dropDownList($track, 'Algorithms', CHtml::listData(Algorithms::model()->findAll(), 'id', 'title'), array("multiple" => true));
?>
	

	<br><br>
	<button type="submit" class="btn btn-success btn-lg">Сохранить</button>

<?php 
$this->endWidget();
?>

<hr>

<script>
	
jQuery(document).ready(function($){
Beispiel #10
0
 /**
  * Computes the critical path in an event-node graph.
  *
  * @param object IDigraph $g An edge-weighted, directed acylic graph.
  * It is assumed that the edge weights are <code>Int</code>s
  * @return object IDigraph A vertex-weighted, directed graph.
  * The events (vertices) on the critical path have zero weight.
  * The one edge that emantes from a vertex connects that vertex
  * to its predecessor on the critical path.
  */
 public static function criticalPathAnalysis(IDigraph $g)
 {
     $n = $g->getNumberOfVertices();
     $earliestTime = new BasicArray($n);
     $earliestTime[0] = 0;
     $g->topologicalOrderTraversal(new EarliestTimeVisitor($earliestTime));
     $latestTime = new BasicArray($n);
     $latestTime[$n - 1] = $earliestTime[$n - 1];
     $g->depthFirstTraversal(new PostOrder(new LatestTimeVisitor($latestTime)), 0);
     $slackGraph = new DigraphAsLists($n);
     for ($v = 0; $v < $n; ++$v) {
         $slackGraph->addVertex($v);
     }
     foreach ($g->getEdges() as $edge) {
         $n0 = $edge->getV0()->getNumber();
         $n1 = $edge->getV1()->getNumber();
         $wt = $edge->getWeight();
         $slack = $latestTime[$n1] - $earliestTime[$n0] - unbox($wt);
         $slackGraph->addEdge($n0, $n1, box($slack));
     }
     return Algorithms::dijkstrasAlgorithm($slackGraph, 0);
 }