Sie sind auf Seite 1von 17

/*

* To change this license header, choose License Headers in Project Properties.


* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tableaux;

/**
*
* @author Ben
*/
public class Exemple_1 {
public static void main(String[] args){
int tab1[]={1,2,3,4,5};
int [] tab2={6,7,8,9,10};
System.out.println("Afficher de tab1: ");
for(int i=0; i<tab1.length; i++)
{System.out.print(tab1[i]+"\t");
}
System.out.println("\n Afficher de tab2: ");
for(int i=0; i<tab2.length; i++)
{System.out.print(tab2[i]+"\t");
}
}

/////////////////////////////
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates

* and open the template in the editor.


*/
package tableaux;

/**
*
* @author Ben
*/
public class Exemple_2 {
public static void main(String[] args){
char [] tab={'a','b','c','d','f','g','h','i','j','l'};
System.out.println("Affichage des tableaux de : ");
for(int i=0; i<tab.length; i++)
{System.out.print(tab[i]+"\t");
}
}

}
//////////////////////
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tableaux;

/**
*
* @author Ben
*/
public class Exemple_3 {

public static void main(String[] args){


String [] jour={"lundi","mardi","mercredi","jeudi","samedi","dimanche"};
System.out.println("Affichage de tableaux du jour: ");
for(int i=0; i<jour.length; i++)
{System.out.print(jour[i]+"\t");
}
}

}
////////////////////////////////

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tableaux;
import java.util.Scanner;

/**
*
* @author Ben
*/
public class Exemple_4 {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int taille;
int [] tab=new int[20];
System.out.println("Ce programme initialiser et affiche un tableaux: ");
System.out.println("Donner la taille du tableaux <=20: ");
taille=sc.nextInt();

System.out.println("Initialisation du tableau: ");


for(int i=0;i<taille;i++){
System.out.println("Donner le element ["+i+"]: ");
tab[i]=sc.nextInt();
}

System.out.println("Affichage du tableau: ");


for(int i=0;i<taille;i++){
System.out.print(tab[i]+"\t");
}
}

}
/////////////////////
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tableaux;

import java.util.Scanner;

/**
*
* @author Ben
*/
public class Exemple_5 {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int taille;

int[] tab;
System.out.println("Ce programme initialiser et affiche un tableaux: ");
System.out.println("Donner la taille du tableaux: ");
taille=sc.nextInt();
tab =new int[taille];
System.out.println("Initialisation du tableau: ");
for(int i=0;i<taille;i++){
System.out.println("Donner le element ["+i+"]: ");
tab[i]=sc.nextInt();
}

System.out.println("Affichage du tableau: ");


for(int i=0;i<taille;i++){
System.out.print(tab[i]+"\t");
}

}
}
////////////////////////
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tableaux;

/**
*
* @author Ben
*/
public class Exemple_6 {

public static void main(String [] args){

int [][] tab={{1,11,12,13,14,15}


,{2,21,22,23,24,25}
,{3,31,32,33,34,35}
};
System.out.println("Ce programme affiche un tableau unitialiser: ");
for(int i=0; i<3; i++){
for(int j=0; j<6; j++){
System.out.print(tab[i][j]+"\t");
}
System.out.println();

}
}
////////////////////
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tableaux;

/**
*
* @author Ben
*/
public class Exemple_7 {
public static void main(String [] args){

int [][] tab={{1,11,12,13,14,15}


,{2,21,22,23,24,25}
,{3,31,32,33,34,35}
};
System.out.println("Ce programme affiche un tableau unitialiser: ");

for(int i=0; i<tab.length; i++){


for(int j=0; j<tab[i].length; j++){
System.out.print(tab[i][j]+"\t");
}
System.out.println();

}
//////////////////////////
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tableaux;
import java.util.Scanner;

/**
*
* @author Ben

*/
public class Exemple_8 {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int [][] tab;
int lign, col;
System.out.println("ce programme initialise et affiche une matrice d'entier: ");
System.out.println("Donner le nbre de ligne: ");
lign=sc.nextInt();
System.out.println("Donner le nbre de colonne: ");
col=sc.nextInt();
tab=new int [lign] [col];
System.out.println("Initialisation de la matrice: ");
for(int i=0;i<lign;i++){
for(int j=0;j<col;j++){
System.out.println("Donner l'element ["+i+"]["+j+"]: ");
tab[i][j]=sc.nextInt();
}
}
System.out.println("Affichage de la matrice: ");
for(int i=0;i<lign;i++){
for(int j=0;j<col;j++){
System.out.print(tab[i][j]+"\t");
}
System.out.println();
}
}
}
///////////////////////////
/*
* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates


* and open the template in the editor.
*/
package tableaux;
import java.util.Scanner;

/**
*
* @author Ben
*/
public class Exemple_9 {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int [][] tab;
int lign,min,col;
System.out.println("ce programme initialise et affiche une matrice d'entier: ");
System.out.println("Donner le nbre de ligne: ");
lign=sc.nextInt();
System.out.println("Donner le nbre de colonne: ");
col=sc.nextInt();
tab=new int [lign] [col];
System.out.println("Initialisation de la matrice: ");
for(int i=0;i<lign;i++){
for(int j=0;j<col;j++){
System.out.println("Donner l'element ["+i+"]["+j+"]: ");
tab[i][j]=sc.nextInt();
}
}
System.out.println("Affichage de la matrice: ");
for(int i=0;i<lign;i++){

for(int j=0;j<col;j++){
System.out.print(tab[i][j]+"\t");
}
System.out.println();
}
min=tab[0][0];
for(int i=0;i<lign;i++){
for(int j=1;j<col;j++){
if(min>tab[i][j])
min=tab[i][j];
}
}
System.out.println("Le plus petit element d'une matrice entiers est: "+min);
}
}
////////////////////////
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tableaux;
import java.util.Scanner;

/**
*
* @author Ben
*/
public class Exemple_10 {
public static void main(String [] args){

Scanner sc=new Scanner(System.in);


int [] tab;
int taille,tmp;
System.out.println("Inversion du tableaux: ");
System.out.println("Initialisation de tableaux a inverser: ");
System.out.println("Donner la taille du tableaux: ");
taille=sc.nextInt();
tab=new int[taille];
for(int i=0;i<tab.length;i++){
System.out.println("Donner l'element["+i+"]: ");
tab[i]=sc.nextInt();
}
System.out.println("Affichage du tableau avant inversion: ");
for(int i=0;i<taille;i++){
System.out.println(tab[i]+"\t");
}
for(int i=0,j=taille-1;i<j;i++,j--){
tmp=tab[i];
tab[i]=tab[j];
tab[j]=tmp;
}
System.out.println("\n Affichage du tableaux invers: ");
for(int i=0;i<taille;i++){
System.out.println(tab[i]+"\t");
}
}
}
/////////////////////////

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package methodes;
import java.util.Scanner;
/**
*
* @author PAPI SARR
*/
public class Exemple_2 {
public static void main(String[] args ){
Scanner sc=new Scanner(System.in);
System.out.println("Donner la taille du tableau a initialiser");
int taille=sc.nextInt();
int []tab=new int[taille];
inittab(tab);
affichetab(tab);
System.out.println("\nLe minimun du tableau est "+mintab(tab));
}
public static void inittab(int []tab){
Scanner sc=new Scanner (System.in);
System.out.println("Initialisation du tableau");
for (int i=0;i<tab.length;i++){
System.out.println("Donner l'elment ["+i+"]:");
tab[i]=sc.nextInt();
}
System.out.println("Initialisation termin avec succ");
}
public static void affichetab(int []tab){
System.out.println("Affichage du tableau: ");
for(int i=0;i<tab.length;i++){
System.out.print(tab[i]+"\t");
}
}
public static int mintab(int tab[]){
int min=tab[0];
for(int i=1;i<tab.length;i++){
if(min>tab[i])
min=tab[i];
}
return min;
}
}

/*
* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates


* and open the template in the editor.
*/
package methodes;
import java.util.Scanner;
/**
*
* @author PAPI SARR
*/
public class Exemple_3 {
public static void main(String[] args){
Scanner sc=new Scanner (System.in);
int [][] tab;
int lign,col;
int min;
System.out.println("Ce programme initialise et affiche une Matrice d'entier");
System.out.println("Donner le nombre de ligne: ");
lign=sc.nextInt();
System.out.println("Donner le nombre de colone: ");
col=sc.nextInt();
tab=new int [lign][col];
System.out.println("Initialisation de la matrice");
for (int i=0;i<lign;i++){
for(int j=0;j<col;j++){
System.out.println("Donner l'element["+i+"]["+j+"]: ");
tab[i][j]=sc.nextInt();
}
}
System.out.println("Affichage de la matrice: ");
for(int i=0;i<lign;i++){
for(int j=0;j<col;j++){
System.out.print(tab[i][j]+"\t");
}
System.out.println();
}
}
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package methodes;
import java.util.Scanner;
/**
*

* @author PAPI SARR


*/
public class Exemple_4 {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
System.out.println("Donner un entier: ");
int a=sc.nextInt();
System.out.println("Donner un autre entier: ");
int b=sc.nextInt();
System.out.println("le produit de "+a+" et "+b+" est "+produit(a,b));
}
public static int produit(int n,int m){
int res=n*m;
return res;
}
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package methodes;
import java.util.Scanner;
public class Exemple_5 {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
float x,y;
System.out.println("operation sur deux nombres: ");
System.out.println("Donner le premier nombre: ");
x=sc.nextFloat();
System.out.println("Donner le second nombre: ");
y=sc.nextFloat();
operation(x,y);
}
////////////////////////////////////////////////////////
public static void operation(float a,float b){
Scanner sc=new Scanner(System.in);
int choix,rep;
float res;
do{
System.out.println("Ce programme opere dux nombres");
System.out.println("Choisir un opration: ");
System.out.println("1- Addition");
System.out.println("2-Soustraction");
System.out.println("3-Multiplication");
System.out.println("4-Division");
System.out.println("Entre le numero de votre choix");

choix=sc.nextInt();
System.out.println("Confirmer votre choix! 1 si oui, un aute chiffre sinon");
rep=sc.nextInt();
}while(rep!=1);
switch(choix){
case 1:
res=a+b;
System.out.println(a+"+"+b+"="+res);
break;
case 2:
res=a-b;
System.out.println(a+"-"+b+"="+res);break;
case 3:
res=a*b;
System.out.println(a+"*"+b+"="+res);break;
case 4:
if(b==0)
{
System.out.println("Le division par zero n'existe pas");
}
else
{
res=a/b;
System.out.println(a+"/"+b+"="+res);
}
break;
}
}
}
.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package methodes;
import java.util.Scanner;

public class Exemple_6 {


public static void main(String[] args ){
Scanner sc=new Scanner(System.in);
System.out.println("Donner la taille du tableau a initialiser");
int taille=sc.nextInt();
int []tab=new int[taille];
inittab(tab);
System.out.println("\nLe minimun du tableau est "+mintab(tab));
}

public static void inittab(int []tab){


Scanner sc=new Scanner (System.in);
System.out.println("Initialisation du tableau");
for (int i=0;i<tab.length;i++){
System.out.println("Donner l'elment ["+i+"]:");
tab[i]=sc.nextInt();
}
System.out.println("Initialisation termin avec succ");
}
public static int mintab(int tab[]){
int min=tab[0];
for(int i=1;i<tab.length;i++){
if(min>tab[i])
min=tab[i];
}
return min;
}
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package methodes;
import java.util.Scanner;

public class Exemple_6 {


public static void main(String[] args ){
Scanner sc=new Scanner(System.in);
System.out.println("Donner la taille du tableau a initialiser");
int taille=sc.nextInt();
int []tab=new int[taille];
inittab(tab);
System.out.println("\nLe minimun du tableau est "+mintab(tab));
}
public static void inittab(int []tab){
Scanner sc=new Scanner (System.in);
System.out.println("Initialisation du tableau");
for (int i=0;i<tab.length;i++){
System.out.println("Donner l'elment ["+i+"]:");
tab[i]=sc.nextInt();
}
System.out.println("Initialisation termin avec succ");
}
public static int mintab(int tab[]){
int min=tab[0];
for(int i=1;i<tab.length;i++){

if(min>tab[i])
min=tab[i];
}
return min;
}
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package methodes;
import java.util.Scanner;
public class Exemple_7 {
public static void main(String[] args ){
Scanner sc=new Scanner(System.in);
double caa=0;
String representant;
System.out.println("Donner le nom du representant: ");
representant=sc.nextLine();
chiffdaffaire(representant,caa);
}
////////////////////////////////////////////////////////////////////////////
public static void chiffdaffaire(String representant,double caa){
Scanner sc=new Scanner(System.in);
double cam;
for(int i=1;i<=12;i++){
System.out.println("Donner le chiffre d'affaire du mois "+i);
cam=sc.nextDouble();
caa=caa+cam;
}
System.out.println("Le chiffre d'affaire annuel de "+representant+" est: "+caa);
}
}

Das könnte Ihnen auch gefallen