Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void main()
- {
- // On demande la taille.
- int taille = readInt();
- // On déclare un tableau de cette taille.
- int[] tableau = new int[taille];
- // On fait remplir le tableau.
- for(int i=0; i < taille; i++)
- {
- tableau[i]=readInt();
- }
- // On déclare une variable pour stocker le maximum,
- // et on l'initialise avec la première valeur du tableau.
- int maximum = tableau[0];
- // On parcourt le tableau...
- for(int i=0; i < taille; i++)
- {
- // ... et on regarde si on trouve un nombre plus grand.
- if(tableau[i] > maximum)
- {
- // Si oui, on change le maximum
- maximum = tableau[i];
- }
- // Si non, bah on fait rien et on passe au suivant.
- }
- println(maximum);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement