reorganisation + hashmap
This commit is contained in:
		
							
								
								
									
										18
									
								
								q2/algo/tp1/Cercle.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								q2/algo/tp1/Cercle.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,18 @@ | ||||
| public class Cercle { | ||||
| 	public static final double PI = 3.14159265; | ||||
|  | ||||
| 	public static void main(String[] args) { | ||||
| 		for (int i = 1; i <= 50; i++) { | ||||
| 			System.out.println("pour un cercle de rayon : " + i + " Perimetre:" +  perimetre(i)+ " aire:" +  aire(i)); | ||||
| 		} | ||||
| 		 | ||||
| 	} | ||||
|  | ||||
| 	public static double perimetre(double rayon){ | ||||
| 		return 2*PI*rayon; | ||||
| 	} | ||||
|  | ||||
| 	public static double aire(double rayon){ | ||||
| 		return PI*rayon*rayon; | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										20
									
								
								q2/algo/tp1/Droites.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								q2/algo/tp1/Droites.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | ||||
| public class Droites { | ||||
| 	public static void main(String[] args) { | ||||
| 		droite(1, 1, 2, 2); | ||||
| 		if(appartient(-1,1, 0, 2, 2)){ | ||||
| 			System.out.println("yay"); | ||||
| 		} | ||||
| 		 | ||||
| 	} | ||||
| 	public static void droite(double x1, double y1, double x2, double y2){ | ||||
| 		double dir_x = x2 - x1, dir_y = y2 - y1; | ||||
| 		double a = -dir_y, b = dir_x; | ||||
| 		double c = a*x1 + b*y1; | ||||
| 		System.out.println("equation de la droite: " + a + "x + " + b + "y = " + c); | ||||
| 	} | ||||
|  | ||||
| 	public static boolean appartient(double a, double b, double c, double x, double y){ | ||||
| 		return a * x + b * y == c ; | ||||
|  | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										18
									
								
								q2/algo/tp1/HelloWorld.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								q2/algo/tp1/HelloWorld.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,18 @@ | ||||
| public class HelloWorld { | ||||
| 	public static void main(String[] args) { | ||||
| 		String prenom = "Anthony"; | ||||
| 		int age = 21; | ||||
| 		double taille = 1.85; | ||||
| 		printHello(prenom, age, taille); | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	public static void printHello(String prenom, int age, double taille) | ||||
| 	{ | ||||
| 		System.out.println("Hello World"); | ||||
| 		System.out.println("Mon nom est " + prenom); | ||||
| 		System.out.println("J'ai " + age + "ans et je mesure " + taille + "m :)"); | ||||
| 	} | ||||
|  | ||||
| 	 | ||||
| } | ||||
							
								
								
									
										32
									
								
								q2/algo/tp1/Suite.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								q2/algo/tp1/Suite.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | ||||
| public class Suite { | ||||
| 	public static void main(String[] args) { | ||||
| 		// suiteArithmetique(5, 5, 3); | ||||
| 		// suiteGeometrique(5, 5, 3); | ||||
| 		suiteFibonacci(15); | ||||
| 	 | ||||
| 	} | ||||
|  | ||||
| 	public static void suiteArithmetique(int depart, int raison, int k){ | ||||
| 		for (int i = 0; i < k; i++) { | ||||
| 			System.out.println(depart + raison * i); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public static void suiteGeometrique(int depart, int raison, int k){ | ||||
| 		for (int i = 0; i < k; i++) { | ||||
| 			System.out.println(depart + (int)Math.pow(raison, i)); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public static void suiteFibonacci(int k){ | ||||
| 		int el1 = 1; | ||||
| 		int el2 = 1; | ||||
| 		int temp; | ||||
| 		for (int i = 0; i < k-2; i++) { | ||||
| 			temp = el1; | ||||
| 			el1 = el2; | ||||
| 			el2 = temp + el2 ; | ||||
| 		} | ||||
| 		System.out.println(el2); | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										
											BIN
										
									
								
								q2/algo/tp1/TP01.pdf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								q2/algo/tp1/TP01.pdf
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user