Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1481 connectés 

  FORUM HardWare.fr
  Programmation
  Java

  Instance qui ne fonctionne pas

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Instance qui ne fonctionne pas

n°2270116
Tcharly94
Posté le 23-11-2015 à 14:13:38  profilanswer
 

package  
 
Bonjour problème avec ce code  
 
public class Evaluation1 {
 
 public static void main (String [] args){
  int[] t1 = {1, 2, 3};
  int[] t2 = {4, 5, 6};
                 
   int[] tab=multiplex(t1, t2);
   for (int i=0; i<tab.length; i++){
    System.out.print(tab[i]);
   }
 }
 /*
  * Compléter les fonctions ci dessous pour répondre aux questions posées.
  */
 
 // Question 1
 static public boolean zeroone(double x, double y) {
  return (x>=0 && x<1) || (y>=0 && y<1);
 }
 
 // Question 2
 static public double moyenne(double [] donnees) {
  double somme=0;
  for (int i=0; i<donnees.length; i++){
   somme=somme+donnees[i];
  }
  double moyenne = somme/(donnees.length);
  return moyenne;
 
 }
 // Question 3
 static public int [] histogram(int [] donnees, int M) {
  int [] tab= new int[M];
  for (int i=0; i<M;i++){
   for (int j=0; j<donnees.length; j++){
    if (donnees[j]==i){
     tab[i]=tab[i]+1;
    }
   }
  }
   
  return tab;
 }
 
 //Question 4
 static public double [][] transpose(double [][] donnees) {
  double [][] transpose = new double [donnees[0].length][donnees.length];
  for (int i=0; i<donnees.length; i++){
   for (int j=0; j<donnees[0].length; j++){
    transpose[j][i]=donnees[i][j];
   }
  }
  return transpose;
 }
 
 // Question 5
 static public double lnfact(double x) {
  public static fact(double y){
   if (y==0){
    return 1;
   }
   else{
    return y*fact(y-1);
   }
  }
  return Math.log(fact(x));
 }
 
 // Question 6
 static public int [] multiplex(int [] a, int [] b) {
  int [] tabMultiplex = new int [a.length+b.length];
  int indexA=0;
  int indexB=0;
  int compteur=0;
  while (indexA<a.length && indexB<b.length){
   for (int i=0;i<tabMultiplex.length; i++){
    if (i%2==0){
     tabMultiplex[i]=a[indexA];
     compteur=i;
     indexA=indexA+1;  
    }
    else{
     tabMultiplex[i]=b[indexB];
     compteur=i;
     indexB=indexB+1;  
    }
   }  
  }
  if (a.length<b.length){
   for (int i=compteur+1; i<tabMultiplex.length; i++){
    tabMultiplex[i]=b[indexB];
   }
  }
  else{
   for (int i=compteur+1; i<tabMultiplex.length; i++){
    tabMultiplex[i]=a[indexA];
  }
  return tabMultiplex;
 }
 
}
 
 
package evaluation1;
 
public class Book {
 String titre;
 double prix;
 int anneePubli;
 String auteur;
 
 public Book(String titre, double prix, int anneePubli, String auteur){
  this.titre=titre;
  this.prix=prix;
  this.anneePubli=anneePubli;
  this.auteur=auteur;
   
 }
 public static void main(String [] args){
  Book robinsonCrusoe = new Book ("Robinson Crusoe",15.50, 1719, "Daniel Defoe" );
  Book heartOfDarkness = new Book ("Heart of Darkness", 12.80, 1902,"Joseph Conrad" );
  Book beachMusic = new Book ("Beach Music", 9.50, 1996, "Pat Conroy" );
   
 }
}

mood
Publicité
Posté le 23-11-2015 à 14:13:38  profilanswer
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Java

  Instance qui ne fonctionne pas

 

Sujets relatifs
Programme qui fonctionne via l'interpreteur mais pas via console linuxce petit code ne fonctionne pas, pourquoi ?
onmouseout qui ne fonctionne pasexportation de graphique d'excel à power point : ne fonctionne qu'une
Serveur Web - cgi_directories ne fonctionne pas comme attendu [Résolu]pourquoi mon premier choix d'une comboliste ne fonctionne pas?
Selection de valeurs d'un champ TCD fonctionne sur 2007 mais pas 2010Problème shell_exec fonctionne pas Graphviz Mediawiki
réplication mysql master/slave ne fonctionne pasExtraction chaine entre parenthèse fonctionne pas
Plus de sujets relatifs à : Instance qui ne fonctionne pas


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR