sustituir un dígito por otro
C
/*
- Pedir un numero de entre 3 y 7 digitos, en caso de que
no este en ese rango volver a pedirlo.
- Pedir dos valores a y b entre 0 y 9, en caso de que no
este en ese rango volver a pedirlo.
- Susituir en el numero inicial el digito a por el digito b
mostrando por pantalla la suma del valor inicial y el valor final.
2325
a:2
b:1
1315
2325 + 1315 = 3640
*/
int a = 0;
int b = 0;
printf("\n\n");
do{
printf("Introduce un numero que tenga entre 3 y 7 digitos: ");
scanf("%d", &n);
}while(n < 100 || n > 10000000 );
printf("Okey, tu numero es correcto\n\n");
do{
printf("Introduce dos valores a y b entre 0 y 9\n");
printf("a: ");
scanf("%d", &a);
printf("b: ");
scanf("%d", &b);
}while(a < 0 || a > 9 || b < 0 || b > 9);
printf("Okey, tus valores son correctos\n");
//Susituir en el numero inicial el digito a por el digito b
int aux = n;
int digito, potencia = 1, nuevo = 0;
while(aux > 0){
digito = aux % 10; //me da el ultimo digito
if(digito == a){
digito = b;
}
nuevo = nuevo + digito * potencia;
potencia = potencia * 10;
aux = aux / 10;
}
printf("inicial: %d\n", n);
printf("final: %d\n", nuevo);
printf("La suma de ambos es: %d\n", n + nuevo);
Also in C:
- Title
- chat
- Category
- C
- Title
- get_session` is not available when using TensorFlow 2.0.
- Category
- C
- Title
- c producer consumer pthread semaphore
- Category
- C
- Title
- how to sleep in c
- Category
- C
- Title
- allocate memory c
- Category
- C
- Title
- sdl bouton
- Category
- C
- Title
- c fill 2d array
- Category
- C
- Title
- c float to int
- Category
- C
- Title
- 233 pounds to inr
- Category
- C
- Title
- c check if file was created
- Category
- C
- Title
- atoi
- Category
- C
- Title
- docker run port mapping
- Category
- C
- Title
- calculate max of three numbers using ternary operator in c
- Category
- C
- Title
- how to use ? in c
- Category
- C
- Title
- compare two chars c
- Category
- C
- Title
- select all file from date powershell
- Category
- C
- Title
- accessing elements of 1d array using pointers
- Category
- C
- Title
- how to convert int in to const char in c
- Category
- C
- Title
- get current used proxy windows 7
- Category
- C
- Title
- stack
- Category
- C
- Title
- delete docker image repository none
- Category
- C
- Title
- how to use a pointer as a parameter in c
- Category
- C
- Title
- windowns 10 allow ping
- Category
- C
- Title
- printf n characters c
- Category
- C
- Title
- full screen on c
- Category
- C
- Title
- c vs python
- Category
- C
- Title
- update ubuntu in terminal
- Category
- C
- Title
- entete
- Category
- C
- Title
- strcat in c
- Category
- C
- Title
- hello world
- Category
- C
- Title
- java.lang.SecurityException: Permission denied (missing INTERNET permission?)
- Category
- C
- Title
- how to check the size of a file c
- Category
- C
- Title
- how to free memory in c
- Category
- C
- Title
- primo
- Category
- C
- Title
- what are the causes of memory leaks in c
- Category
- C
- Title
- c isdigit function
- Category
- C
- Title
- triangulo
- Category
- C
- Title
- does strcat null terminate
- Category
- C
- Title
- curl post request
- Category
- C
- Title
- c how to define a variable
- Category
- C
- Title
- how to login to another user in powershell
- Category
- C
- Title
- restapi
- Category
- C
- Title
- variadic function in c
- Category
- C
- Title
- what is a long long int in c
- Category
- C
- Title
- measure time in c
- Category
- C
- Title
- switch case c
- Category
- C
- Title
- get a remote branch git
- Category
- C
- Title
- sue murry
- Category
- C
- Title
- function in c
- Category
- C
- Title
- declaring a volatile in c
- Category
- C
- Title
- msdos
- Category
- C
- Title
- convert string to float c
- Category
- C
- Title
- c value set to zero __memmove_avx_unaligned_erms
- Category
- C
- Title
- how to check the size of a file in linux c
- Category
- C
- Title
- fibonacci in c
- Category
- C
- Title
- vbl share price
- Category
- C
- Title
- oop244
- Category
- C
- Title
- error: ‘istringstream’ is not a member of ‘std’
- Category
- C
- Title
- inurl:fiu.edu math faculty
- Category
- C
- Title
- command line arguments c
- Category
- C
- Title
- CL/cl.h: No such file or directory
- Category
- C
- Title
- \0 in c
- Category
- C
- Title
- how to call the tkinter insert command from another class
- Category
- C
- Title
- error 403
- Category
- C
- Title
- how to go to top of file in vim
- Category
- C
- Title
- version of libgcc
- Category
- C
- Title
- ModuleNotFoundError: No module named 'cv2'
- Category
- C
- Title
- div
- Category
- C
- Title
- reverse function in c
- Category
- C
- Title
- doubly linked list c
- Category
- C
- Title
- /usr/bin/mandb: fopen /var/cache/man/7935: Permission denied
- Category
- C
- Title
- router solicitation and advertisement magic is used by
- Category
- C
- Title
- tkinter create_line
- Category
- C
- Title
- c concatenate strings
- Category
- C
- Title
- strrev in c
- Category
- C
- Title
- python web crawler
- Category
- C
- Title
- how to find the ith row of pascal's triangle in c
- Category
- C
- Title
- buscar caracter
- Category
- C
- Title
- confirm sweet alert
- Category
- C
- Title
- .\main.c:4:8: error: expected declaration specifiers or '...' before '\x6f726c64'
- Category
- C
- Title
- printf("%3d ",XX);
- Category
- C
- Title
- find gcd iteratively
- Category
- C
- Title
- reset style matplotlib
- Category
- C
- Title
- docker images command
- Category
- C
- Title
- c check if array is empty
- Category
- C
- Title
- networkx remove attributes
- Category
- C
- Title
- disable gnu++11 option
- Category
- C
- Title
- how to comment in arduino
- Category
- C
- Title
- slurm array job
- Category
- C
- Title
- FILE*
- Category
- C
- Title
- xamarin command listview button
- Category
- C
- Title
- c check if char is an operator
- Category
- C
- Title
- entete c/c++
- Category
- C
- Title
- error: ‘cout’ was not declared in this scope
- Category
- C
- Title
- what is size_t in c
- Category
- C
- Title
- c string concatenation with int
- Category
- C
- Title
- mangoosejs
- Category
- C
- Title
- sustituir un dígito por otro
- Category
- C
- Title
- how to mutex lock in c
- Category
- C
- Title
- c program to count duplicates in an array
- Category
- C