35 lines
742 B
C
35 lines
742 B
C
|
#include<stdlib.h>
|
||
|
#include<stdio.h>
|
||
|
#include<string.h>
|
||
|
#include<math.h>
|
||
|
|
||
|
int puissance(int a, int b){
|
||
|
int c;
|
||
|
int resultat=0;
|
||
|
for (c=0;c<b;c++){
|
||
|
resultat = resultat*resultat;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int strint(char chaine[10]){
|
||
|
int digit=strlen(chaine)-1;
|
||
|
int longueur=digit;
|
||
|
int resultat=0;
|
||
|
for (;digit>=0;digit--){
|
||
|
printf(("%d = %d * 10**%d\n",(int)chaine[digit]), (int)chaine[digit])*puissance(10,(-digit+longueur)),(-digit+longueur));
|
||
|
resultat += ((int)chaine[digit])*puissance(10,(-digit+longueur));
|
||
|
}
|
||
|
return(resultat);
|
||
|
}
|
||
|
|
||
|
int main(int argc, char** argv) {
|
||
|
if (argc > 1) {
|
||
|
int resultat;
|
||
|
resultat = strint(argv[1]);
|
||
|
printf("%d\n",resultat);
|
||
|
} else {
|
||
|
puts("aucun argument !");
|
||
|
}
|
||
|
return EXIT_SUCCESS;
|
||
|
}
|