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 20124233 at 2014-04-18 17:33:19
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
 using namespace std; 
  bool ff1=false,ff2=false;
 char a[100],b[100];
   int c[100];
   int main(){
    int m,len,dex,ans,dd,cc;
    while(cin>>m&&m){
    	memset(b,' ',sizeof(b));
    	memset(c,0,sizeof(c));
    	ans=0;
    	cc=0;
        cin>>a;
      len=strlen(a);
     for(int i=0;i<len;i++){
       ff1=false;ff2=false;
       for(int k=0;k<m;k++){
		    if(a[i]!=b[k]){
		      continue;
      		}else{
      		  ff2=true;
      		  dd=k;
      		  break;
      		}
  	   }
	 if(!ff2){
       for(int j=0;j<m;j++){
         if(b[j]==' '){
            b[j]=a[i];
            ff1=true;
            break;
         }else {
		    continue; 
			}
       }
	   if(ff1)continue;	
       if(!ff1&&c[a[i]-'A']==0){
       	 c[a[i]-'A']=1;
	    ans++;continue;
	   }else
         continue;	       
 	 }else{
 	    b[dd]=' ';
	    continue;  
 	 }
    }
    if(ans==0)cout<<"All customers tanned successfully."<<endl;
    else
      cout<<ans<<" customer(s) walked away."<<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