HDOJ HDU 1106 排序 ACM 1106 IN HDU
生活随笔
收集整理的這篇文章主要介紹了
HDOJ HDU 1106 排序 ACM 1106 IN HDU
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
//MiYu原創(chuàng), 轉(zhuǎn)帖請注明 : 轉(zhuǎn)載自?______________白白の屋
題目地址 :
????????????http://acm.hdu.edu.cn/showproblem.php?pid=1106
很簡單的一道水題, 就是直接字符串拆分就行了
代碼:?
//MiYu原創(chuàng), 轉(zhuǎn)帖請注明 : 轉(zhuǎn)載自?______________白白の屋
#include?<stdio.h>
#include?<stdlib.h>
#include?<string.h>
int?cmp?(?const?void?*p,?const?void?*t?)
{
????return?*(int?*)p?-?*(int?*)t;
}
char?s[1010];
int?a[1010];
int?main()
{
????while?(?scanf("%s",s)?!=?EOF?)
????{
??????????char?*t;
??????????int?n?=?1;
??????????memset?(?a,?0,?sizeof?(?a?)?);
??????????t?=?strtok?(?s,"5"?);
??????????a[0]?=?atoi?(?t?);
??????????while?(?t?=?strtok?(?NULL,"5"?)?)
??????????{
?????????????????a[?n?++?]?=?atoi?(?t?);????
??????????}
??????????qsort?(?a,?n,?sizeof?(?int?),?cmp?);
??????????for?(?int?i?=?0;?i?!=?n;?++?i?)
??????????{??
????????????????printf(i???"?%d"?:?"%d",a[i]);
??????????}
??????????putchar?(?'\n'?);
????}
????return?0;
}
題目地址 :
????????????http://acm.hdu.edu.cn/showproblem.php?pid=1106
很簡單的一道水題, 就是直接字符串拆分就行了
代碼:?
//MiYu原創(chuàng), 轉(zhuǎn)帖請注明 : 轉(zhuǎn)載自?______________白白の屋
#include?<stdio.h>
#include?<stdlib.h>
#include?<string.h>
int?cmp?(?const?void?*p,?const?void?*t?)
{
????return?*(int?*)p?-?*(int?*)t;
}
char?s[1010];
int?a[1010];
int?main()
{
????while?(?scanf("%s",s)?!=?EOF?)
????{
??????????char?*t;
??????????int?n?=?1;
??????????memset?(?a,?0,?sizeof?(?a?)?);
??????????t?=?strtok?(?s,"5"?);
??????????a[0]?=?atoi?(?t?);
??????????while?(?t?=?strtok?(?NULL,"5"?)?)
??????????{
?????????????????a[?n?++?]?=?atoi?(?t?);????
??????????}
??????????qsort?(?a,?n,?sizeof?(?int?),?cmp?);
??????????for?(?int?i?=?0;?i?!=?n;?++?i?)
??????????{??
????????????????printf(i???"?%d"?:?"%d",a[i]);
??????????}
??????????putchar?(?'\n'?);
????}
????return?0;
}
轉(zhuǎn)載于:https://www.cnblogs.com/MiYu/archive/2010/08/18/1802398.html
總結(jié)
以上是生活随笔為你收集整理的HDOJ HDU 1106 排序 ACM 1106 IN HDU的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle10g- emctl sta
- 下一篇: HDOJ 1253 HDU 1253 胜