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

同一个代码,多交几次,oj的判定就不同。为什么???谢谢。。

Posted by kamel52045386 at 2007-10-29 13:09:07 on Problem 1731
#include<stdio.h>
#include<cstdlib>
#include<string.h>
#include<functional>
#include<algorithm>
using namespace std;
int cmp(const void *a,const void *b)
{
 char e,f;
 e=(*((char *)a));
 f=(*((char *)b));
 if(e>f) return 1;
 if(e<f) return -1;
 return 0;    
}
int find2(char *a,int b)
{
 int i=1;
 while(i<b)
 {
  if(a[i]<=a[i-1])
  i++; 
  else return 0;         
 }    
 if(i==b) return -1;

}
int findbig(char *a,int b)
{
int i;
i=b-1;
while(i>=0)
{
 if(a[i]>a[i-1])
 return i;
 else
 i--;           
}    
}
void swap(char *a,int e,int f)
{
 char c;
 c=a[e];
 a[e]=a[f];
 a[f]=c;     
}
int findsmall(char *a,int e,int len)
{
 int i,j,small;
 char min;
 i=e-1;
 j=e;
 min='z';
 while(j<len)
 {
  if(a[j]>a[i]&&a[j]<min)
  {
   min=a[j];
   small=j;
  }
  j++;     
  
 }
 return small;
 
 
}
int main()
{
char content[201];
int len,find,big,small;
gets(content);
len=strlen(content);
sort(content,content+len,less<char>());
printf("%s\n",content);
while(find2(content,len)!=-1)
{
 big=findbig(content,len);
 small=findsmall(content,big,len);
 swap(content,small,big-1);
 sort(content+big,content+len,less<char>());
 printf("%s\n",content);
}
//system("pause");
return 0;    
}

2843526 kamel52045386 1731 Accepted 144K 77MS C++ 1268B 2007-10-29 13:03:37 
2843523 kamel52045386 1731 Accepted 72K 46MS C++ 1268B 2007-10-29 13:02:19 
2843500 kamel52045386 1731 Accepted 144K 77MS C++ 1268B 2007-10-29 12:54:49 
2843498 kamel52045386 1731 Accepted 144K 61MS C++ 1268B 2007-10-29 12:54:45 


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