Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:谁能告诉我sort里面的比较函数怎么写么,一直错In Reply To:谁能告诉我sort里面的比较函数怎么写么,一直错 Posted by:earnAlive at 2014-04-14 21:48:18 > #include<stdio.h> > #include<string.h> > #include<algorithm> > using namespace std; > > bool cmp(char *str1,char *str2) > { > return strcmp(str1,str2); > } > > int main() > { > int m,n; > int i; > scanf("%d%d",&m,&n); > char str[m][n]; > for(i=0;i<m;i++) > { > scanf("%s",str[i]); > } > sort(str[0],str[m],cmp); > for(i=0;i<m;i++) > printf("%s\n",str[i]); > return 0; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator