#include <stdio.h>
#include <string.h>
void my_seek(
char *
str,
int a[],
float b[])
{
int i =
0;
int j =
0;
int k =
0;
int temp1 =
0;
float ch =
0.1;
float temp2 =
0.0;
while(*
str)
{
while(((*
str >=
'0')&&(*
str <=
'9'))||*
str ==
'.')
{
while(*
str >=
'0'&&*
str <=
'9')
{
temp1 = temp1*
10+*
str-
'0';
str++;
}
if(*
str ==
'.')
{
temp2 = temp1;
str++;
while(*
str >=
'0'&&*
str <=
'9')
{
temp2 = temp2+(*
str-
'0')*ch;
str++;
ch = ch *
0.1;
}
b[j] = temp2;
j++;
}
else
{
a[i] = temp1;
i++;
}
}
temp1 =
0;
temp2 =
0.0;
str++;
}
printf(
"字符串中的整数为:\n");
for(k =
0;k < i; k++ )
{
printf(
"%d ",a[k]);
}
printf(
"\n");
printf(
"字符串中的浮点数为:\n");
for(k =
0;k < j;k++)
{
printf(
"%g ",b[k]);
}
printf(
"\n");
}
int main()
{
char str[
100] = {
0};
int a[
100] = {
0};
float b[
100] = {
0.0};
printf(
"please input string:\n");
scanf(
"%s",
str);
my_seek(
str,a,b);
return 0;
}