A voir également:
- Aider moi s'il vous plait dans ces 2 exercice
- Supercopier 2 - Télécharger - Gestion de fichiers
- 2 ecran pc - Guide
- Faire 2 colonnes sur word - Guide
- Whatsapp 2 - Guide
- Word numéro de page 1/2 - Guide
5 réponses
/* Nombre d'Armstrong */
#include<stdio.h>
#include<conio.h>
#define cub(x) (x*x*x)
int main()
{
long int i,x,Som;
for(i=0;i<1000000;i++)
{
x=i;
Som=0;
do
{
Som+=cub((x%10));
x=x/10;
}
while(x>0);
if(Som==i)
printf("%d est un nombre d'Armstrong\n",i);
}
getch();
}
#include<stdio.h>
#include<conio.h>
#define cub(x) (x*x*x)
int main()
{
long int i,x,Som;
for(i=0;i<1000000;i++)
{
x=i;
Som=0;
do
{
Som+=cub((x%10));
x=x/10;
}
while(x>0);
if(Som==i)
printf("%d est un nombre d'Armstrong\n",i);
}
getch();
}
En php je t'ai fait ça pour le premier exo:
<?php echo "Nombres Amstrong<br><br>"; for($nbr=100;$nbr<=500;$nbr++){ $ch1=substr($nbr,0,1); $ch2=substr($nbr,1,1); $ch3=substr($nbr,2,1); if($nbr==($ch1*$ch1*$ch1)+($ch2*$ch2*$ch2)+($ch3*$ch3*$ch3)){ echo "nombre: ".$nbr."<br><br>"; } } ?>
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
merci d avance