Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:谁能告诉我sort里面的比较函数怎么写么,一直错

Posted by zhjou at 2014-05-12 00:21:39 on Problem 1007
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator