v1 Transitividade - Snipt.org

The Easiest Way to Save and Share Code Snippets on the web

Your snipt has been migrated to #newsnipt successfully.

Transitividade

java

posted: May, 12th 2009 | jump to bottom

class prog{
	public static void main(String[] arg){
		boolean[][] b = {{false,true,false},{false,false,false},{false,false,false}};
		System.out.print("Transitividade: "+checaTransitividade(b));
	}
	static boolean checaTransitividade(boolean[][] r){
		for (int x=0;x<r.length;x++){
			for (int y=0;y<r.length;y++){
				for (int z=0;z<r.length;z++){
					if (r[x][y]==r[y][z] && r[x][y]!=r[x][z])
						return false;
				}
			}
		}
		return true;
	}
}
2 views