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:就是不知道自己错在那里,在本机上VS和G++都通过的,一提交就是runtime error

Posted by keven218 at 2007-04-17 10:32:07 on Problem 1007
In Reply To:就是不知道自己错在那里,在本机上VS和G++都通过的,一提交就是runtime error Posted by:liuweni at 2006-11-28 15:08:22
> #include <iostream>
> #include <string>
> 
> using namespace std;
> int i;
> void sort(int num[],string str[],int first  ,int last)
> {
>      int itemp;
>      string stemp;
>      if(first == last)
>       return;
> 
>      for(i = first ; i != last ; i++) 
>      {
>       if( num[first] > num[i])
>         {
> 		itemp = num[i];num[i] = num[first];num[first] = itemp;
> 		stemp = str[i];str[i] = str[first];str[first] = stemp;
>     	}
>      }
>      for(i = last ; i != first ;i--)  
>      {
>       if(num[last] < num[i])
>       {
> 		itemp = num[i];num[i] = num[last];num[last] = itemp;
> 		stemp = str[i];str[i] = str[last];str[last] = stemp;
>        }
>      }
>      sort(num,str,first + 1,last);
>      sort(num,str,first,last - 1);
> } 
> int main()
> {
> 	int a,b;
> 	int *num;
> 	string *str;
> 	cin>>a;
> 	num = new int[a];
> 	str = new string[a];
> 	cin>>b;
> 	for(i = 0 ; i < b ; i++)
> 	{
> 		cin>>str[i];
> 		num[i] = 0;
> 
> 		for(int j = 0 ; j < a ;j ++)
> 		{
>                 for(int ii = j ;ii < a ;ii++)
>                 {
> 		        	if(str[i][j]>str[i][ii])
>                     {
> 			        	num[i] ++;
>                      }
>                 }
>           } 
> 	}
> 	sort(num , str , 0 , b-1);
> 	
> 	for(i = 0 ; i < b ; i++)
> 	{
> 		cout<<str[i]<<endl;
> 	}
> 	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