Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- main()
- {
- char cad1[25], cad2[25], numa[4], numb[4], *p;
- int num1, num2, i,j=0;
- printf("Ingrese la cadena 1: \n");
- setbuf(stdin, NULL);
- gets(cad1);
- printf("Ingrese la cadena 2: \n");
- setbuf(stdin, NULL);
- gets(cad2);
- for(i=0;i<25;i++)
- {
- if(cad1[i] >= 48 && cad1[i] <= 57)
- {
- for(j=0;j<3;j++)
- {
- //printf("%d ", i);
- p=&cad1[i];
- numa[j]=*p;
- i++;
- }
- }
- numa[3]='\0';
- }
- j=0;
- for(i=0;i<25;i++)
- {
- if(cad2[i] >= 48 && cad2[i] <= 57)
- {
- p=&cad2[i];
- numb[j]=*p;
- j++;
- }
- numb[3]='\0';
- }
- printf("\nA: %s B: %s", numa,numb);
- num1=atoi(numa);
- num2=atoi(numb);
- printf("\nLa suma de los numeros es: %d \n\n", num1+num2);
- }
Advertisement
Add Comment
Please, Sign In to add comment