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

快崩溃了,为什么总是过不了,已经试过好几百次

Posted by 00448067 at 2005-03-03 19:16:37 on Problem 2232
>#include <iostream.h>
>int n;
>int i,m,j,num;
>char win,temp;

>int cmp(char c1,char c2)
>{
>	if(c1=='S')
>	{if(c2=='C')
>	    return 1;
>	else
>		return 0;}
>	else if(c1=='F')
>	{if(c2=='S')
>	    return 1;
>	else
>		return 0;}
>	else
>	{if(c2=='F')
>	    return 1;
>	else
>		return 0;}
>}
>
>void main()
>{ cin>>n;
>char * A=new char[n];
> int * I=new int[n];
> int * J=new int[n];
> m=n;
> for(i=0;i<n;i++)
>	{ cin>>A[i];  }         
> for(i=0;i<n;i++)
>	{I[i]=0; 
>	 J[i]=0;}
> do{
>	 win=A[0];
>	 for(i=1;i<m;i++)
>	 { if(cmp(win,A[i]))
>	    { win=A[i];
>	      j=i;}
>
>	 }
>	 if((j+m-n+1)%m==0)
>        J[n-1]=m;
>	 else
>		J[n-1]=(j+m-n+1)%m;	 
>	 temp=A[0];
>     for(i=1;i<m;i++)
>	 {A[i-1]=A[i];}
>	 A[m-1]=temp;
>	 j=0;
> }while(--n>0);
> 
> for(i=0;i<m;i++)
>	{ ++I[*(J+i)-1];}
> for(i=0;i<m;i++)
> { if(I[i]!=0)
>    num++;  }
> 
> cout<<num<<endl;
>}

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