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 chenxuan123456789 at 2012-11-05 18:51:55 on Problem 1451
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
const int size = 10010;
typedef struct
{
        char str[10];
        int count;
}Node;
Node node[size];
char hash[30]="22233344455566677778889999";
int n,times;
int cmp(const void *_a,const void *_b)
{
    Node *a=(Node*)_a;
    Node *b=(Node*)_b;
    return b->count-a->count;
}
void result(char s[])
{
     int lens,len,i,j,k,flag,c=0,l;
     lens=strlen(s);
	 j=0;
     for(i=1;i<=n;i++)
     {
                      len=strlen(node[i].str);
					  flag=0;
                      for(;j<len;j++)
                      {
						  for(k=0;k<j;k++)
							  if(hash[node[i].str[k]-'a']!=s[k])
							  {
								  flag=1;
								  break;
							  }
							  if(flag)
								  break;
							  else
							  {
								  if(hash[node[i].str[j]-'a']==s[j])
								  {
									  c++;
									  for(k=0;k<=j;k++)
										  cout<<node[i].str[k];
									      cout<<endl;
								  }
								  else
								  {
									  break;
								  }
							  }
					  }
	 }
	 for(l=c+1;l<lens;l++)
	 cout<<"MANUALLY"<<endl;
}
int main()
{
    int cases,m,i;
    char s1[10];
    cin>>cases;
	times=1;
    while(cases--)
    {
                  cin>>n;
                  for(i=1;i<=n;i++)
                  cin>>node[i].str>>node[i].count;
                  qsort(node+1,n,sizeof(node[0]),cmp);
				  cout<<"Scenario #%d:"<<times<<endl;
                  cin>>m;
                  while(m--)
                  {
                            cin>>s1;
							if(strcmp(s1,"1"))
                            result(s1);
						   	if(m>1)
						  	cout<<endl;
                  }
    }
    return 1;
}


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