//07.01.09
//Guo R.H
#include
#include
#include
#define CHAR 1
#define NUMBER 0
#define BUFSIZE 10
char buf[BUFSIZE];
int bufp = 0;
int getch()
{
return bufp == 0?getchar():buf[--bufp];
}
void ungetch(int c)
{
buf[bufp++] = c;
}
int gettop(char s[])
{
char c;
int i=0;
s[0] = c = getch();
if(c == EOF)
return c;
if (!isdigit(c))
{
while(!isdigit( s[++i] = c = getch() ) && c != EOF)
;
ungetch(c);
s[i] = '\0';
return CHAR;
}
if(isdigit(c))
{
while(isdigit( s[++i] = c = getch() ))
;
ungetch(c);
s[i] = '\0';
return NUMBER;
}
}
int main()
{
char ch[10][50], tc[50];
double a[5];
int flag, i=0, j, k=0, l;
while((flag = gettop(tc)) != EOF)
{
j=0;
l=0;
if(flag == CHAR)
{
while(ch[i][l++] = tc[j++])
;
i++;
}
else
a[k++] = atof(tc);
}
for(j=0; j printf("%lf ", a[j]);
for(j=0; j printf("%s ", ch[j]);
return 0;
}
阅读(830) | 评论(0) | 转发(0) |