Input:
The first line of the input contains T denoting the
number of testcases. First line of each test case will
be an alphanumeric string.
Output:
For each test case output will be a numeric string
after removing all the characters.
Constraints:
1 <= T <= 30
1 <= size of string <= 100
Example:
Input:
1
AA123BB4
Output:
1234
#include <iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
char a[100];
int i;
cin>>a;
for(i=0;a[i]!='\0';i++)
{
if(a[i]>='0'&&a[i]<='9')
cout<<a[i];
}
cout<<"\n";
}
return 0;
}
The first line of the input contains T denoting the
number of testcases. First line of each test case will
be an alphanumeric string.
Output:
For each test case output will be a numeric string
after removing all the characters.
Constraints:
1 <= T <= 30
1 <= size of string <= 100
Example:
Input:
1
AA123BB4
Output:
1234
#include <iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
char a[100];
int i;
cin>>a;
for(i=0;a[i]!='\0';i++)
{
if(a[i]>='0'&&a[i]<='9')
cout<<a[i];
}
cout<<"\n";
}
return 0;
}
No comments:
Post a Comment