Created
April 20, 2018 04:07
-
-
Save arthur-es/3801b4f6a59fea2887c8860ad83055ad to your computer and use it in GitHub Desktop.
john account
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<math.h> | |
//what a mess neto<3 apagaisso* | |
main(){ | |
int numC,inversoNumC,somaNumCcomNumCInverso,multiOPMaisSoma,digitoVerificador; | |
printf("Entre com o numero da conta: \n"); | |
scanf("%d",&numC); | |
if(numC < 1000 && numC > 0){ | |
printf("NUMERO DA CONTA: %d\n",numC); | |
//algarismo de numC | |
int aux = 0, a,b,c; //var auxiliar | |
aux = numC; | |
a = aux/100; // pega o primeiro algarismo do YXX | |
b = (aux/10)%10; //pega o segundo algarismo do XYX | |
c = aux%10; //pega o terceiro num do XXY | |
//somaNumCcomNumCInverso numero da conta com seu inverso: | |
//inverso | |
inversoNumC = c*100 + b*10 + a; | |
somaNumCcomNumCInverso = inversoNumC + numC; | |
//printf("SOMA: %d\n",somaNumCcomNumCInverso); //debug | |
//printf("INVERSO: %d\n",inversoNumC); //debug | |
//algarismo de SOMA (somaNumCcomNumCInverso) | |
aux = somaNumCcomNumCInverso; | |
a = aux/100; // pega o primeiro algarismo do YXX | |
b = (aux/10)%10; //pega o segundo algarismo do XYX | |
c = aux%10; //pega o terceiro num do XXY | |
//multiplicar cada digito pela sua ordem posicional e somar estes resultados | |
multiOPMaisSoma = c * 1 + b*2 + a*3; | |
//printf("multiOPMaisSoma : %d\n",multiOPMaisSoma); //debug | |
//ultimo digito desse resultado: | |
digitoVerificador = multiOPMaisSoma%10; | |
//printf("Digito verificador: %d\n",digitoVerificador); //debug | |
//numC passa a ser: | |
printf("NUMERO DA CONTA: %d-%d\n",numC,digitoVerificador); | |
} else printf("Numero de conta invalido! \n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment