This question requires extracting all numeric characters ('0'……'9') in a string and converting them into an integer for output.
Input format:
Input a string that does not exceed 80 characters and ends with a carriage return in one line.
Output format:
output the converted integer in one line. The title guarantees that the output does not exceed the long integer range.
Input sample:
free82jeep5
Output sample:
825
title collection complete works portal
#include <stdio.h>
#include <string.h>
int main()
{
char c[81];
int n = 1, sum = 0;
gets(c);
for (int i = strlen(c); i >= 0; i--)
if (c[i] >= '0' && c[i] <= '9')
{
sum += n * (c[i] - 48);
n *= 10;
}
printf("%d", sum);
return 0;
}