Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente | Prochaine révision Les deux révisions suivantes | ||
ens:dasi2014:juint [2014/04/03 08:17] admin Cordier Amelie () [Partie 2. Exercices simples] |
ens:dasi2014:juint [2014/04/03 09:54] admin Cordier Amelie () |
||
---|---|---|---|
Ligne 50: | Ligne 50: | ||
| | ||
public int sum(String s) { | public int sum(String s) { | ||
- | if (s=="" | + | if (s==" ") return 0; |
- | if (s.length ()==1 return ((int)(s.charAt(0))); | + | if (s.length ()==1) return ((int)(s.charAt(0))); |
return ((int)(s.charAt(0))) + sum(s.substring(1)); | return ((int)(s.charAt(0))) + sum(s.substring(1)); | ||
} | } | ||
| | ||
public String binarise(int x) { | public String binarise(int x) { | ||
- | if (x==0) return ""; | + | if (x==0) return " "; |
if (x%2==1) return " | if (x%2==1) return " | ||
return " | return " |