Partage de codes sources - CodesWall.info
Java
> bigint
Titre
bigint
Postée le
26-10-2009
Affichée
546
Mini-lien
Description
BigInt
Etat
Ne contient pas d'erreurs.
Code d'insertion
Options
Tweet
Téléchargement
import java.util.ArrayList;
class
Test
{
public
static
class
BigInt
{
private
ArrayList
<
Integer
>
l
;
public
BigInt
(
int
n
)
{
l =
new
ArrayList
<
Integer
>
(
)
;
while
(
n
>
0
)
{
l.
add
(
n
%
10
)
;
n/=
10
;
}
}
public
void
fois
(
int
n
)
{
ArrayList
<
Integer
>
lRes =
new
ArrayList
<
Integer
>
(
)
;
int
res=
0
;
int
s = l.
size
(
)
;
for
(
int
i=
0
;
i
<
s
;
++i
)
{
res += l.
get
(
i
)
*
n
;
lRes.
add
(
res
%
10
)
;
res /=
10
;
}
while
(
res
>
0
)
{
lRes.
add
(
res
%
10
)
;
res /=
10
;
}
l = lRes
;
}
public
int
sommeChiffres
(
)
{
int
somme =
0
;
int
s = l.
size
(
)
;
for
(
int
i=
0
;
i
<
s
;
++i
)
somme += l.
get
(
i
)
;
return
somme
;
}
public
String
toString
(
)
{
String
str =
new
String
(
)
;
for
(
int
i=l.
size
(
)
-1
;
i
>
=
0
;
--i
)
str += l.
get
(
i
)
;
return
str
;
}
}
;
public
static
int
sommeFactorielle
(
int
n
)
{
BigInt bn =
new
BigInt
(
n
)
;
for
(
int
i=n
-1
;
i
>
1
;
--i
)
bn.
fois
(
i
)
;
return
bn.
sommeChiffres
(
)
;
}
public
static
void
main
(
String
[
]
arg
)
{
System
.
out
.
println
(
sommeFactorielle
(
100
)
)
;
}
}
;
Postez votre code-source
Informations
Catégorie *
-
Php
javascript
CSS
HTML
Xml
Perl
C
C++
Java
VB.Net
Script Batch
C#.Net
Visual Basic
VBA
Shell
mIRC
Latex
OCaml
pascal
MySQL
MatLab
Fichier .ini
SmallTalk
Autre
Titre *
(50 car. max)
Description *
(200 car. max)
Le code
Fonctionne
Ne fonctionne pas
Je ne sais pas
Source
* : Champs obligatoires
Fermer
Accueil
Poster
Actualités
Règles
Contact
Partenaires
Infos / Aide
Php
(58)
javascript
(35)
CSS
(20)
HTML
(16)
Xml
(17)
Perl
(11)
C
(64)
C++
(51)
Java
(48)
VB.Net
(5)
Script Batch
(8)
C#.Net
(4)
Visual Basic
(6)
VBA
(5)
Shell
(10)
mIRC
(3)
Latex
(6)
OCaml
(4)
pascal
(9)
MySQL
(13)
MatLab
(3)
Fichier .ini
(5)
SmallTalk
(1)
Autre
(17)
\n
Forum informatique