This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Station { | |
private final String name; | |
Station( String name ) { | |
this.name = name; | |
} | |
public String getName() { | |
return this.name; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Line { | |
private final String name; | |
private final int time; | |
Line( String name,int time ) { | |
this.name = name; | |
this.time = time; | |
} | |
public String getName() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.jgrapht.Graph; | |
import org.jgrapht.GraphPath; | |
import org.jgrapht.graph.WeightedMultigraph; | |
import org.jgrapht.alg.interfaces.ShortestPathAlgorithm.SingleSourcePaths; | |
import org.jgrapht.alg.shortestpath.DijkstraShortestPath; | |
public class ShortestPath { | |
public static void main( String args[] ) { | |
// グラフオブジェクトを作成 | |
Graph<Station,Line> graph = new WeightedMultigraph<>(Line.class); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Line { | |
private final String name; | |
private final int price; | |
private final int time; | |
Line( String name, int price, int time ) { | |
this.name = name; | |
this.price = price; | |
this.time = time; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person implements Comparable { | |
private int id; | |
private String name; | |
public Person( int id, String name ) { | |
this.id = id; | |
this.name = name; | |
} | |
public Person() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <string> | |
#include <iostream> | |
#include <ctime> | |
class Person { | |
private: | |
int id; | |
std::string name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <string> | |
#include <iostream> | |
#include <ctime> | |
class Person { | |
private: | |
int id; | |
std::string name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
class Person : Comparable{ | |
let id : Int | |
let name : String | |
init( id : Int, name : String ) { | |
self.id = id; | |
self.name = name; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_array( N, num ): | |
# 長さNの配列を用意し0で初期化 | |
array = N * [0] | |
# 各要素にnumを代入 | |
for i in range(N): | |
array[i] = num | |
# 各要素の和を計算 | |
sum = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Collections; | |
public class test{ | |
private static int test_arraylist( int N, int num ) { | |
// 長さNの配列を用意し0で初期化 | |
ArrayList<Integer> array = new ArrayList<Integer>( Collections.nCopies(N, 0) ); | |
// 各要素にnumを代入 | |
for ( int i = 0; i < N; i++ ) { |
NewerOlder