Breaking News
Loading...
Monday, July 15, 2013

Hàm tách các số trong chuỗi ra thành mảng riêng

7/15/2013 09:19:00 AM
void tachso(char *s)
{
int a[100],j=0;
for(int i=0;i<strlen(s);i++)
if(s[i]>='0' && s[i]<='9')
{        a[j]=s[i];//ki tu kieu char chuyen thanh kieu int(vd:1=>49)
j++;
for(int t=i;t<strlen(s);t++)
s[t]=s[t+1];
i--;
}
puts(s);
for(int i=0;i<j;i++)
cout<<char(a[i])<<" ";
}

0 comments:

Post a Comment

 
Toggle Footer