0051231232050775
0 77 12312320
//考查知识点:strtok函数的简单应用。
/*
strtok(char *s,char *a)函数每次只能在字符串 s 中 找到 字符串 a ,
并将 在s中存在的位置,设置为 NULL (即'\0'),没办法一次在s 中将所有
的 与 a 相等的字符串截取。char *s,char *a ;都必须是 字符串的起始地址
要将一个字符串s 中的所有的 都截取了,可以用循环。
char *b=strtok(s,a);
while(b!=NULL)
{
//t.insert(atoi(b));
b=strtok(NULL,c);
}
*/
#include<stdio.h>
#include<set>
#include<string.h>
using namespace std;
char a[1010];
char c[2]={'5'};
int atoi(char *s)
{
int len=strlen(s);
int sum=0;
for(int i=0;i<len;++i)
sum=sum*10+s[i]-'0';
return sum;
}
int main()
{
while(~scanf("%s",a))
{
char *b=strtok(a,c);
multiset<int>t;
while(b!=NULL)
{
t.insert(atoi(b));
b=strtok(NULL,c);
}
multiset<int >::iterator it;
it=t.begin();
printf("%d",*it);
it++;
while(it!=t.end())
{
printf(" %d",*it);
it++;
}
puts("");
}
return 0;
} 原文地址:http://blog.csdn.net/ice_alone/article/details/44398477