写一个程序,把一个字符串中的数字子序列找出来并转换成十进制整数输出。
Input
第一行是整数nn,表示测试的数据组数,下面是nn行无空格的字符串(长度不超过200)。题目保证字符串中含的整数位数小于99位,不考虑负数情形。
Output
每一行输入对应一行输出,一行中若有多个数据,每个数据后有一个空格。
Sample Input
1 00tUrA-Hc:T#7yN`;J0123Y+'-rD%\SV`{)e'9;Lt[^$}~0
Sample Output
0 7 123 9 0
Hint
#include <iostream>
#include<string.h>
#include<stdio.h>
#include<string>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
char s[201];
scanf("%s",s);
int len=strlen(s);
int i,sum=0;
for(i=0; i<len; i++)
{
if(s[i]>='0'&&s[i]<='9')
{
sum+=s[i]-'0';
if(s[i+1]>='0'&&s[i+1]<='9')
{
sum*=10;
}
else
{
printf("%d ",sum);
sum=0;
}
}
}
printf("\n");
}
return 0;
}